【问题标题】:how to do division in python without decimal points [duplicate]如何在没有小数点的python中进行除法[重复]
【发布时间】:2020-11-21 16:21:42
【问题描述】:

如果我使用 integer 类型转换技术,那么它不适用于像 12630717197566440063

这样的大数字

在某些情况下我得到了错误的答案,比如下面的 python 3

a =12630717197566440063;
print(a)
temp = a/10
print(int(temp))

然后我得到 1263071719756644096 作为答案,而不是 1263071719756644006

【问题讨论】:

  • temp = a // 10

标签: python integer


【解决方案1】:

您可以使用//(地板除法)运算符:

temp = a//10
print(temp)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-09-13
    • 1970-01-01
    • 2021-12-26
    • 2017-09-22
    • 1970-01-01
    • 1970-01-01
    • 2015-11-23
    • 1970-01-01
    相关资源
    最近更新 更多