V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
panghua
V2EX  ›  问与答

请问在 python3 中如何将 string 类型转换为 decimal.Decimal 类型?

  •  
  •   panghua · 2018-08-21 18:30:19 +08:00 · 3639 次点击
    这是一个创建于 2073 天前的主题,其中的信息可能已经有所发展或是发生改变。

    在 python3 中如何将 string 类型转换为 decimal.Decimal 类型

    3 条回复    2018-11-12 17:31:05 +08:00
    zjb861107
        1
    zjb861107  
       2018-08-21 18:35:26 +08:00
    panghua
        2
    panghua  
    OP
       2018-08-22 11:59:35 +08:00
    谢谢!
    tqknight
        3
    tqknight  
       2018-11-12 17:31:05 +08:00
    import decimal

    dec = decimal.Decimal('0.123456')
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3234 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 13:16 · PVG 21:16 · LAX 06:16 · JFK 09:16
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.