我的代码:
#!/usr/bin/python
# -*- coding: utf-8 -*-
print (round(1.555, 1)) # It seems normal
print (round(1.555, 2)) # Why it is not output 1.56?
print (round(1.556, 2)) # It seems normal
输出:
sam@sam:~/code/python$ ./t2.py
1.6
1.55
1.56
sam@sam:~/code/python$
round(1.555, 1)
输出1.6
。
为什么不round(1.555, 2)
输出1.56
?