In Python all objects, Python programs can be decomposed into modules, statements, expressions and objects. As shown below:
1 program consists of modules
2 module contains statements
3 statement contains an expression
4 expression creation and processing of an object
Built-in objects (core types):
1) Number:
>>> #整数加法
4
>>> 1.5*4 #浮点数乘法
6.0
>>> 2**10 #2的10次方
1024
2) String:
>>> s= ' ABCDEFG '
>>> Len (s) #len函数验证变量的长度
7
>>> S[0] #获取某个元素
A
>>> S[1]
' B '
>>> S[-1] #反向索引
' G '
>>> S[len (s)-3]
E
>>> s[1:] #分片
' BCDEFG '
>>> s
' ABCDEFG '
>>> S[:3]
' ABC '
>>> S[:-1]
' ABCdef '
>>> s+ ' xyz ' #字符串合并
' Abcdefgxyz '
>>> s= ' F ' +s[3:] #建立一个新的字符串 and named with the same variable name to change its assignment
>>> s
' FDEFG '
3) List
>>> l=[123, ' spam ', 1.23]
>>> L
[123, ' spam ', 1.23]
>>> L[0] #显示列表一个元素
123
>>> L + [4,5,6]
[123, ' spam ', 1.23, 4, 5, 6]
>>> m=[[1,2,3], #嵌套
... [4,5,6],
... [7,8,9]]
>>> M
[[1, 2, 3], [4, 5, 6], [7, 8, 9]]
>>> M[0] #显示第一行
[1, 2, 3]
>>> M[0][2] #显示第一行中的第3个元素
3
Not to be continued ...
This article from "10,000 years too long, seize" blog, please be sure to keep this source http://zengwj1949.blog.51cto.com/10747365/1928404
Python Learning manual Note (1): Python object type