如何在python中打印大数的所有数字?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27325704/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 01:40:10  来源:igfitidea点击:

How to print all digits of a large number in python?

pythonnumbers

提问by Nicholas D Yson

So, I have a very large number that I'm working out in python, but when I try to print it I get something like this:

所以,我有一个非常大的数字,我正在用 python 计算,但是当我尝试打印它时,我得到了这样的东西:

3.101541146879488e+80

How do I print all the digits of my lovely number?

如何打印我可爱号码的所有数字?

回答by Bhargav Rao

both intand longwork for this

intlong为这项工作

>>> a
3.101541146879488e+80
>>> int(a)
310154114687948792274813492416458874069290879741385354066259033875756607541870592L
>>> long(a)
310154114687948792274813492416458874069290879741385354066259033875756607541870592L
>>> print (int(a))
310154114687948792274813492416458874069290879741385354066259033875756607541870592
>>> print (long(a))
310154114687948792274813492416458874069290879741385354066259033875756607541870592