'{:.ne}'.format()科学计数法
如未指定精度n,则用小数点之后 6
位精度。
'{:.n%}'.format()取百分比
n指定精度。
math.ceil()向上取整
ceil:在英文中,有「天花板」的意思,在上面,所以,此函数是向上取整。
math.floor()向下取整
同样,floor在英文中有地板的意思,在下面,所以,此函数是向下取整。
round()四舍五入
math.modf()取小数、取整数部分
int()取整数
math.fabs()取绝对值
math.gcd()取两个数最大公约数
math.sqrt()开平方
math.pi取圆周率派
math.e取常数e
math.exp()取e的n次方
math.pow(x, y)取x的y次方
math.log2()取以2为底的对数
math.log10()取以10为底的对数
math.log(x, y)
三角函数
- math.sin()取正弦值
- math.cos()取余弦值
- math.tan()取正切值
反三角函数
- math.acos()取反余弦值
- math.asin()取反正弦值
- math.atan()取反正切值
双曲函数
- math.cosh()取双曲余弦值
- math.sinh()取双曲正弦值
- math.tanh()取双曲正切值
- math.acosh()取反双曲余弦值
- math.asinh()取反双曲正弦值
- math.atanh()取反双曲正切值
cmath操作复数
Reference
https://docs.python.org/zh-cn/3/library/string.html#format-specification-mini-languagehttps://docs.python.org/zh-cn/3/library/math.html?highlight=math#module-math
https://docs.python.org/zh-cn/3/library/cmath.html?highlight=math#module-cmath