Python长整数输入 [英] Python long integer input

查看:161
本文介绍了Python长整数输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Python 2.7中获取"long int"输入?

How can one take a "long int" input in Python 2.7?

P.S.我尝试了n=(*(raw_input()))的各种变体,但无济于事.

P.S. I tried various variations of n=(*(raw_input())) but to no avail.

推荐答案

n = int(raw_input())

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

This will convert the input to an integer. Since Python employs arbitrary precision arithmetic, we don't have to worry about how big the number is.

>>> n = int(raw_input())
100000000000000
>>> n
100000000000000L

这篇关于Python长整数输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆