【问题标题】:Get value to the right of the decimal in python [duplicate]在python中获取小数点右边的值[重复]
【发布时间】:2020-06-04 02:21:13
【问题描述】:

如果我打印 5/4,我得到 1.25。我怎样才能得到 .25 部分。

print(5/4)
1.25 

【问题讨论】:

  • 这能回答你的问题吗? How to get numbers after decimal point?
  • 这听起来像是一个 X/Y 问题——你实际上想做什么?几乎可以肯定不会得到小数点右边的数字(即25
  • 你能用5/4 % 1吗?

标签: python


【解决方案1】:

不是最优雅的解决方案,但这会奏效

print(5/4-5//4)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多