文档介绍:Pyton 分享
2011/05/01
Outline
概述
Python内建对象类型
代码
概述
/python/ ivepython
2. 参考文档
python分享\diveintopython-- \.chm
3. 代码风格
每行程序以换行符代表结束,如果一行程序太长的话, 可以用“\”符号扩展到下一行
“”“标识注释
返回
Python内建对象类型
>>> import sys
>>> print
2147483647
>>> type()
<type 'int‘>
Python内建对象类型
2. String字符串型
“\”可允许把字符串放于多行
helptext="""this a help you have any quesions. hope so as you."""
“+”号可连接字符串。
“*”号重复字符串,如:‘hello’*5
string[start:end]
\' 单引号
Python内建对象类型
3. List 介绍
>>> li = ["a", "b", "mpilgrim", "z", "example"]
>>> li[0] # list 索引
'a'
>>> li[-1],li[-3]
('example', 'mpilgrim')
>>> li[1:-1]
[‘b’, ‘mpilgrim’, ‘z’] #list 切片
Python内建对象类型
3. Tuple 介绍
 Tuple 没有方法,不可变的LIST
>>> t = ("a", "b", "mpilgrim", "z", "example")
>>> t[0]
'a'
>>> t
('a', 'b', 'mpilgrim', 'z', 'example')
>>> ('new')
Traceback (most recent call last):
File "<pyshell