What is float('123.987') in Python?
It's 开发者_高级运维123.98699999999999 !
Why is that?
See Why can't decimal numbers be represented exactly in binary
The Python FAQ and tutorial address this issue pretty well, I think. More generally, both are excellent resources, well worth your time to browse if you have any interest in Python!-)
This has changed in/since Python 3.1.
See also: issue 1580
To your (already deleted) addition: Use the decimal package.
精彩评论