转载:
http://www.yiibai.com/python/python_strings.html
文章转载自:易百教程 [http:/www.yiibai.com]
单双引号一样
a='hello'
2、访问字符串值
a='sadfsdf'
切片的方法
a[0]
a[1:3]
3、转义字符
遇到\会转义
4、字符串特殊操作符
a='hello,'
b='python'
+ 字符串合并
* 重复
[] 切片,取索引值
[:] 范围切片
in 成员判断符
not in
r/R 禁止转义字符,如print(a'\n')
% 格式化字符
5、字符串格式化操作
类似于C
6、三重引号字符串
使得字符串可以跨越多行
如
a='''sadf f
asdf sadf
'''
7、unicode字符串
print(u'hello the world')
8、字符串内置
各种字符串函数
如
upper()
isdecimal()
http://www.yiibai.com/python/python_strings.html
文章转载自:易百教程 [http:/www.yiibai.com]
以下为自己概括:
字符串
1、创建字符串单双引号一样
a='hello'
2、访问字符串值
a='sadfsdf'
切片的方法
a[0]
a[1:3]
3、转义字符
遇到\会转义
4、字符串特殊操作符
a='hello,'
b='python'
+ 字符串合并
* 重复
[] 切片,取索引值
[:] 范围切片
in 成员判断符
not in
r/R 禁止转义字符,如print(a'\n')
% 格式化字符
5、字符串格式化操作
类似于C
6、三重引号字符串
使得字符串可以跨越多行
如
a='''sadf f
asdf sadf
'''
7、unicode字符串
print(u'hello the world')
8、字符串内置
各种字符串函数
如
upper()
isdecimal()