《转》python学习(6)序列类型-字符串
2017-03-26 15:38
489 查看
转自 http://www.cnblogs.com/BeginMan/archive/2013/06/08/3125502.html
二、序列类型
包含字符串、列表、元祖。模式都一样,举一反三即可。如:
1、成员关系操作符(in / not in )
2、关于切片
要灵活运用。
三、关于序列类型的内建函数
如list()、tuple()、str()类型转换,实际上是工厂函数,浅copy的结果而并非真正的改头换面(转换)。
注意在string类型上应用list()、tuple()往往并不能得到我们想要的结果。
序列类型的内建函数一览表:
cmp()、len()、max()、min()、enumerate()、zip()、
四、Unicode字符串
五、字符串类型的内建方法
1、不常用的string模块
打开这个string.py模块,如下:
不常用,很多功能可以自己模拟。
2、内建函数
join/split:http://www.cnblogs.com/BeginMan/archive/2013/03/21/2972857.html
二、序列类型
包含字符串、列表、元祖。模式都一样,举一反三即可。如:
1、成员关系操作符(in / not in )
2、关于切片
三、关于序列类型的内建函数
如list()、tuple()、str()类型转换,实际上是工厂函数,浅copy的结果而并非真正的改头换面(转换)。
注意在string类型上应用list()、tuple()往往并不能得到我们想要的结果。
序列类型的内建函数一览表:
cmp()、len()、max()、min()、enumerate()、zip()、
四、Unicode字符串
1 >>> 'hello'+u' '+'world' 2 u'hello world'
五、字符串类型的内建方法
1、不常用的string模块
1 >>> import string 2 >>> string.uppercase 3 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 4 >>> string.lowercase 5 'abcdefghijklmnopqrstuvwxyz' 6 >>> string.whitespace 7 '\t\n\x0b\x0c\r ' 8 >>> string.digits 9 '0123456789' 10 >>> string.punctuation 11 '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'
打开这个string.py模块,如下:
....................................... # Some strings for ctype-style character classification whitespace = ' \t\n\r\v\f' lowercase = 'abcdefghijklmnopqrstuvwxyz' uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' letters = lowercase + uppercase ascii_lowercase = lowercase ascii_uppercase = uppercase ascii_letters = ascii_lowercase + ascii_uppercase digits = '0123456789' hexdigits = digits + 'abcdef' + 'ABCDEF' octdigits = '01234567' punctuation = """!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~""" printable = digits + letters + punctuation + whitespace # Case conversion helpers .......................................
不常用,很多功能可以自己模拟。
2、内建函数
join/split:http://www.cnblogs.com/BeginMan/archive/2013/03/21/2972857.html
相关文章推荐
- Python学习笔记(四)序列类型与字符串
- python学习之路二(字符串,字典,序列和元组)
- python 学习笔记 二 序列, 列表, 元组, 字符串
- Python3学习(一)-基础、数据类型、变量、字符串和编码、list&tuple、if、for、while、dict、set、函数与参数
- Python新手学习基础之数据类型——字符串的切片截取
- Python学习笔记(一)--Python基础知识:变量、数据类型、模块与字符串
- python学习之路二(字符串,字典,序列和元组)
- Python教程学习简记1--Python数据类型和变量 字符串和编码 list和tuple 条件判断 循环 dict和set
- python学习笔记2—python文件类型、变量、数值、字符串、元组、列表、字典
- Python教程学习简记1--Python数据类型和变量 字符串和编码 list和tuple 条件判断 循环 dict和set
- Python新手学习基础之数据类型——字符串的切片截取
- Python快速学习02:基本数据类型 & 序列
- Python学习笔记 -- 序列(一)序列类型
- python学习 数据类型之序列
- python学习笔记2-核心类型-字符串
- Python快速学习02:基本数据类型 & 序列
- Python学习笔记 -- 序列(二)字符串
- Python学习(三)---常见类型转换、数值操作、序列操作
- Python新手学习基础之数据类型——字符串类型
- Python3学习笔记03-基本数据类型、序列、运算及缩进和选择