- 变量
1.1 无需定义,需要的时候直接使用
1.2 命名规则
1.2.1 字母或下划线开头
1.2.2 字母、数字、下划线组成
1.3 保留字(不可作为变量名)
and | as | assert | break | class | continue |
def | del | elif | else | except | False |
finally | for | from | global | if | import |
in | is | lambda | none | nonlocal | not |
or | pass | raise | return | True | try |
while | with | yield |
1.4 内置函数函数名(可以作为变量名,但函数功能失去)
abs() | all() | any() | apply() | baaestring() |
bin() | bool() | buffer() | bytearray() | callable() |
chr() | classmethod() | cmp() | coerce() | compile() |
complex() | delattr() | dict() | dir() | divmod() |
enumerate() | eval() | execfile() | file() | filter() |
float() | format() | frozenset() | getattr() | globals() |
hasattr() | hash() | help() | hex() | id() |
input() | int() | intern() | isinstance() | issubclass() |
iter() | len() | list() | locals() | long() |
map() | max() | memoryview() | min() | next() |
object() | oct() | open() | ord() | pow() |
print() | property() | range() | raw_input() | reduce() |
reload() | repr() | reversed() | round() | set() |
setattr() | slice() | sorted() | staticmethod() | str() |
sum() | super() | tuple() | type() | unichr() |
unicode() | vars() | xrange() | zip() | _import() |
2. 数学运算
2.1 基本运算符
加 | + |
减 | - |
乘 | * |
除 | / |
整除 | // |
求余 | % |
次方 | ** |
2.2 优先级
次方>乘、除、整除、求余>加、减
2.3 赋值运算符
+= | -= | *= | /= | //= | %= | **= |
2.4 等号多重指定使用
多个变量赋同一个值 | a=b=c=10 |
多个变量赋不同值 | a,b,c=10,20,30 |
多个变量交换内容 | a,b,=b,a |
2.5 删除变量
del 变量名
2.6 断行(一行写不下)
1. 在最后加 "\" 符号。
注:在 "\" 符号右边不能加如何东西,包括注释符号
2. 多行内容放在小括号里面
注:语句右边可以加注释符号