推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
996bujiaban
V2EX  ›  Python

求解, Python 怎么保留大数

  •  
  •   996bujiaban · Nov 27, 2022 · 3727 views
    This topic created in 1399 days ago, the information mentioned may be changed or developed.

    如题 a=12345672644298357.857212458 print(a) 1.2345672644298358e+16

    a 会自动变成科学数,失去了后面的小数点

    用 int 或者 float 也会四舍五入

    目的是要用完整的 a 来进行计算

    4 replies  •  2022-11-27 20:51:02 +08:00
    BrettD
        1
    BrettD  
       Nov 27, 2022 via iPhone   ❤️ 1
    BBCCBB
        2
    BBCCBB  
       Nov 27, 2022
    decimal. java 里较 Bigdecimal
    Red998
        3
    Red998  
       Nov 27, 2022
    字符串解决一切
    hefish
        4
    hefish  
       Nov 27, 2022
    1#是正解。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2775 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 13:24 · PVG 21:24 · LAX 06:24 · JFK 09:24
    ♥ Do have faith in what you're doing.