'{:.ne}'.format()科学计数法

如未指定精度n,则用小数点之后 6 位精度。

python 取整天花板 python天花板函数_nagios

'{:.n%}'.format()取百分比

n指定精度。

python 取整天花板 python天花板函数_qml_02

math.ceil()向上取整

ceil:在英文中,有「天花板」的意思,在上面,所以,此函数是向上取整。

python 取整天花板 python天花板函数_python 取整天花板_03

math.floor()向下取整

同样,floor在英文中有地板的意思,在下面,所以,此函数是向下取整。

python 取整天花板 python天花板函数_3d_04

round()四舍五入



python 取整天花板 python天花板函数_qml_05

math.modf()取小数、取整数部分



python 取整天花板 python天花板函数_qml_06

int()取整数



python 取整天花板 python天花板函数_python 取整天花板_07

math.fabs()取绝对值



python 取整天花板 python天花板函数_3d_08

math.gcd()取两个数最大公约数



python 取整天花板 python天花板函数_3d_09

math.sqrt()开平方



python 取整天花板 python天花板函数_python 取整天花板_10

math.pi取圆周率派



python 取整天花板 python天花板函数_sms_11

math.e取常数e



python 取整天花板 python天花板函数_sms_12

math.exp()取e的n次方



python 取整天花板 python天花板函数_nagios_13

math.pow(x, y)取x的y次方



python 取整天花板 python天花板函数_nagios_14

math.log2()取以2为底的对数



python 取整天花板 python天花板函数_3d_15

math.log10()取以10为底的对数



python 取整天花板 python天花板函数_python 取整天花板_16

math.log(x, y)



python 取整天花板 python天花板函数_3d_17

三角函数

  • 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