【发布时间】:2021-01-08 21:15:20
【问题描述】:
我想在数学模块中添加一个函数log100():
def log100(number):
ans = math.log(number,100)
return ans
如果不使用“os”模块来添加目录,我看不到怎么做。
【问题讨论】:
标签: python-3.x
我想在数学模块中添加一个函数log100():
def log100(number):
ans = math.log(number,100)
return ans
如果不使用“os”模块来添加目录,我看不到怎么做。
【问题讨论】:
标签: python-3.x
虽然这不是最好的主意——你可能会因为混淆标准模块而让后来阅读你的代码的人感到困惑——你可以做类似的事情
math.log100 = lambda x: math.log(x, 100)
或
def log100(x):
return math.log(x, 100)
math.log100 = log100
,然后可以称为
math.log100(10) # Output 0.5
【讨论】: