Python标准库-数字的处理函数(math模块)

         Python标准库-数字的处理函数(math模块)

                                      作者:尹正杰

版权声明:原创作品,谢绝转载!否则将追究法律责任。

 1 #!/usr/bin/env python
 2 #_*_conding:utf-8_*_
 3 #@author :yinzhengjie
 4 #blog:http://www.cnblogs.com/yinzhengjie
 5 
 6 import math
 7 
 8 #取整
 9 print(math.floor(3.1))
10 print(math.floor(3.6))
11 
12 #取整并加1
13 print(math.ceil(5.1))
14 print(math.ceil(5.6))
15 
16 #查看PI的值
17 print(math.pi)
18 
19 #查看自然常数
20 print(math.e)
21 
22 
23 
24 
25 #以上代码输出结果如下:
26 3
27 3
28 6
29 6
30 3.141592653589793
31 2.718281828459045
原文地址:https://www.cnblogs.com/yinzhengjie/p/11106371.html