例如:
>>> s = 'python' >>> s.index('') 0 >>> s.index('p') 0
python string
我正在考虑在Python中舍入浮点数,以下行为似乎很奇怪:
代码:
a = 203.25 print '%.2f'%(a/10.) print '%.2f'%(round(a/10., 2)) print '%.2f'%(0.1*a)
输出:
20.32 20.32 20.33
为什么第一个,特别是第二个案例失败了?
python floating-accuracy
python ×2
floating-accuracy ×1
string ×1