标签:
math模块、cmath模块
floor:向下取整
ceil:向上取整
sqrt:求平方根
>>> import math
>>> math.floor(1.1)
1
>>> math.ceil(1.1)
2
>>> math.sqrt(1)
1.0
>>> math.sqrt(-1)
Traceback (most recent call last):
File "<pyshell#17>", line 1, in <module>
math.sqrt(-1)
ValueError: math domain error
>>> import cmath
>>> cmath.sqrt(-1)
1j
>>>
标签:
原文地址:http://www.cnblogs.com/liuhuan2368935760/p/4660546.html