Python长整数输入

Vis*_*and 6 python input python-2.7

如何在Python 2.7中使用"long int"输入?

PS我尝试了各种各样的变化n=(*(raw_input()))但无济于事.

the*_*eye 6

n = int(raw_input())
Run Code Online (Sandbox Code Playgroud)

这会将输入转换为整数.由于Python采用任意精度算法,因此我们不必担心数字有多大.

>>> n = int(raw_input())
100000000000000
>>> n
100000000000000L
Run Code Online (Sandbox Code Playgroud)

  • Python中有`long`类型,但它与C标准的`long`不同 - 它具有任意精度,超过int precision的任何`int`对象都变为`long`.`>>> type(int(10000000000))== long; TRUE` (3认同)