2022
我们一起努力

python中如何写入log函数

python中使用log函数的方法

在python中使用log函数时,log()函数无法直接访问,需要先导入math模块,在通过静态对象调用;

log():log函数的作用是返回一个数的自然对数。

log()函数语法:

import math

math.log(x[, base])

使用方法:

import math #导入math模块

print "math.log(100.12) : ", math.log(100.12)

print "math.log(100.72) : ", math.log(100.72)

print "math.log(119L) : ", math.log(119L)

print "math.log(math.pi) : ", math.log(math.pi)

# 设置底数

print "math.log(10,2) : ", math.log(10,2)

输出结果为:

math.log(100.12) : 4.60636946656

math.log(100.72) : 4.61234438974

math.log(119L) : 4.77912349311

math.log(math.pi) : 1.14472988585

math.log(10,2) : 3.32192809489

赞(0)
文章名称:《python中如何写入log函数》
文章链接:https://www.fzvps.com/37594.html
本站文章来源于互联网,如有侵权,请联系管理删除,本站资源仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。
图片版权归属各自创作者所有,图片水印出于防止被无耻之徒盗取劳动成果的目的。

评论 抢沙发

评论前必须登录!