math.log(1000,10)2.9999999999999996
为什么执行不是3啊?讲道理不就应该是3吗
这是浮点数误差。可以用numpy库的对数函数,比较精确
import numpy numpy.log10(1000) #3.0
浮点误差