Professional Documents
Culture Documents
Built in Functions
Function Description
--
Example
x = pow(4, 3)
64
Python String Methods
Method Description
--
Python List/Array Methods
Method Description
extend() Add the elements of a list (or any iterable), to the end of
the current list
index() Returns the index of the first element with the specified
value
--
Python Dictionary Methods
Method Description
items() Returns a list containing a tuple for each key value pair
setdefault( Returns the value of the specified key. If the key does
) not exist: insert the key, with the specified value
Python Tuple Methods
Method Description
Method Description
Method Description
as To create an alias
if To make a conditional
statement
or A logical operator
Method Description
常用的数学函数
函数名 用法 模块 说明
abs(x) 返回数字的绝对值 内置
返回浮点数 x 的四
round(x [, n]) 内置 n 表示小数点位数
舍五入值
返回给定参数的最
max(x1, x2, …) 内置 参数可以为序列
大值
返回给定参数的最
min(x1, x2, …) 内置 参数可以为序列
小值
mat
返回数字的上入整
ceil(x) 例如:math.ceil(4.1)返回 5
数
h
mat
exp(x) 返回 e 的 x 次幂
h
mat
fabs(x) 返回数字的绝对值
h
mat
返回数字的下舍整
floor(x)
数
h
mat
log(x) 返回 x 的自然对数 x>0
h
x 对数 h
mat
返回 x 的整数部分 两部分的数值符号与 x 相
modf(x)
和小数部分 h 同,整数部分以浮点型表示
mat
power(x, y) x**y 运算后的值 x**y 表示 x 的 y 次方
h
mat
返回数字 x 的平方
sqrt(x)
根 h