数据类型:
不可变的类型:
bool, int, float, complex, str, tuple, frozenset, bytes(后面会讲)
可变的数据类型:
list, dict, set, bytearray(后面会讲)
值:
None, False, True
运算符:
+ - * / // % **
> >= < <= == !=
not and or
in, not in
& | ^
+(正号) -(负号)
表达式:
100
100 + 200
len([1,2,3]) + max([1,2,3]) # 函数调用是表达式
print("hello")
条件表达式: x if x > y else y
全部的推导式: [x for x in range(5)]
(列表,字典,集合推导式三种)
语句 statement
表达式语句:
print("hello world")
'hello'
赋值语句:
a = 100
a = b = c = 200
x, y, z = 100, 200, 300
if 语句
while 语句
for 语句
break 语句
continue 语句
pass 语句
del 语句
内建函数:
len(x)
max(x)
min(x)
sum(x)
any(x)
all(x)
构造函数:
bool(x)
int(x, base=10)
float(x)
complex(real=0, image=0)
str(x)
list(x)
tuple(x)
dict(x)
set(x)
frozenset(x)
数字处理函数:
abs(x)
round(x)
pow(x, y,z=0)
字符串相关函数:
bin(x)
oct(x)
hex(x)
chr(x)
ord(x)
迭代器相关:
range(start, stop, step)
reversed(x)
sorted(x)
输入输出相关:
input(x)
print(...)
详见:
>>> help(__builtins__)