【问题标题】:how to represent integer infinity in python 3? [duplicate]如何在 python 3 中表示整数无穷大? [复制]
【发布时间】:2022-01-26 13:32:17
【问题描述】:

我有一个类型注释为 int 的变量。我想为它分配一个任意大的值作为默认值。如果是 float,我可以使用 ma​​th.inf。但是,如果变量是整数,我应该使用什么?

def calc(x: int = math.inf):
        ...

【问题讨论】:

    标签: python-3.x integer infinity


    【解决方案1】:

    我没有办法这样做。你可以坚持浮动。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-03-19
      • 2021-02-23
      • 1970-01-01
      • 2016-04-30
      • 1970-01-01
      • 1970-01-01
      • 2018-01-09
      • 2014-12-28
      相关资源
      最近更新 更多