相关疑难解决方法(0)

在python中以科学记数法打印非常大的长度

有没有办法让python以科学记数法打印极大的长片?我说的是大约10 ^ 1000或更大的数字,在这个尺寸下标准打印"%e"%num失败.

例如:

Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41) 
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print "%e" % 10**100
1.000000e+100
>>> print "%e" % 10**1000
Traceback (most recent call last):
  File "", line 1, in 
TypeError: float argument required, not long

似乎python试图将long转换为float然后打印它,是否有可能让python只用科学记数法打印长而不将其转换为浮点数?

python

14
推荐指数
3
解决办法
7043
查看次数

标签 统计

python ×1