Python学习笔记(四)字符串
2017-11-08 18:46
288 查看
获取字符串
str="hello" print str[0] #输出h,第一个字符从0开始计数。
字符串拼接
1.可通过加号“+”将字符串拼接2.乘号“*”代表将字符串重复输出
>>> str1="welcome" >>> str2="girls" >>> print str1+str2 welcomegirls >>> print str*2 hellohello >>>
格式化字符串(“%”)
格式化:将不同类型的变量通过%显示出来>>> print "I am a %s and my height is %d cm!"%("girl",170) I am a girl and my height is 170 cm! #字符串用%s,整数用%d
相关文章推荐
- Python学习笔记4-字符串和序列
- Python学习笔记(五):字符串
- Python学习笔记-- 字符串和数字的连接
- python学习笔记:字符串操作大全
- Python 学习笔记-字符串
- [Python学习笔记][第四章Python字符串]
- Python学习笔记-第三章 使用字符串
- python学习笔记6.9-通过字符串访问类的方法
- 【Python-学习笔记】字符串的规则
- Python 学习笔记(1)——字符串的处理
- python学习笔记05(字符串与list)
- Python下字符串的创建和转义字符的使用 - 千月的python linux 系统管理指南学习笔记(10)
- 【零基础入门学习Python笔记003】插曲之变量和字符串|课习题答案
- 【Python】学习笔记——-2.2、字符串和编码
- Python学习笔记 - 字符串的方法
- 简明python教程学习笔记之十-DocStrings文档字符串
- python学习笔记20(字符串格式化)
- Python学习笔记1―Python字符串
- Python学习笔记(三)字符串
- Python学习笔记(四)序列类型与字符串