快速学习链接:
http://www.cnblogs.com/vamei/archive/2012/09/13/2682778.html
number bool str
转义:
/n 换行
/r 回车
字符打印操作:
>>> print("hello \\n world.")
hello \n world.
>>> print(r"hello \n world")
hello \n world
字符的组合,切割:(字符串运算):
>>> "hello "+"world"
'hello world'
>>> "hello"*3
'hellohellohello'
>>> "hello world"[0]
'h'
>>> "hello world"[1]
'e'
>>> "hello world"[-1]
'd'
>>> "hello world"[0:4]
'hell'
>>> "hello world"[0:-1]
'hello worl'
>>> "hello world"[0:20]
'hello world'
>>> "hello world"[6:]
'world'
>>> "hello world"[-5:]
'world'
系列类型: list
>>> ["one","two","three","four"][0:]
['one', 'two', 'three', 'four']
>>> ["one","two","three","four"][-1:]
>>> ["one","two","three","four"][0]
'one'
>>> ["one","two","three","four"][0:2]
['one', 'two']
>>> ["one","two","three","four"]+["five","six"]
['one', 'two', 'three', 'four', 'five', 'six']
>>> ["one","two","three","four"]*2
['one', 'two', 'three', 'four', 'one', 'two', 'three', 'four']
>>> type([1,2])
<class 'list'>
嵌套分组
>>> [["1","11"],[2,22]]
[['1', '11'], [2, 22]]
元组类型:
>>> (1,True)
(1, True)
>>> (1,True,"22")
(1, True, '22')
>>> (1,True,"22")*2
(1, True, '22', 1, True, '22')
>>> type((1,2))
<class 'tuple'>
当为一个元素的时候,元组与系列显示
<class 'list'>
>>> type([1])
<class 'list'>
>>> type((1))
<class 'int'>
>>> type(("srt"))
<class 'str'>
>>> (1)
1
>>> (1,)
(1,)