Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/355.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 程序显示为几位数_Python_Digits - Fatal编程技术网

Python 程序显示为几位数

Python 程序显示为几位数,python,digits,Python,Digits,这个程序计算2的平方根,但它不会显示我想要的1000位精度的数字,而是只显示50位数字 这是节目单 import math a=format(2.0**0.5, '.1000') print a 我想知道如何写一个程序来显示更多的数字 使用模块: 使用模块: 看看数学 导入mpmath mpmath.mp.dps=1000 打印mpmath.sqrt2.0 1.414213562373095048801688724209698078856569671875376948073176679

这个程序计算2的平方根,但它不会显示我想要的1000位精度的数字,而是只显示50位数字

这是节目单

import math 
a=format(2.0**0.5, '.1000')   
print a
我想知道如何写一个程序来显示更多的数字

使用模块:

使用模块:

看看数学

导入mpmath

mpmath.mp.dps=1000

打印mpmath.sqrt2.0

1.414213562373095048801688724209698078856569671875376948073176679737990732474662107038850387534327641572735013846230091229702492483605585077212644121497099358331412266592750559275579995050127820 605714701095599716059702745345968620147285174186408891986095523292304843087143214508397626036279952514079896872533965463318088296406206152583523950547457502877599617298355752203375318570113543746 034084988471603868999706990048150305440277903164542478230684929369186215805784631115966687130130156185689872372352885092648612494977154218334204285686060146824720771435854874155657069677653720226 485447015858801620758474922657226002085584466521458398893944370926591800311388246468157082630100594858704003186480342194897278290641045072636881313739855256117322040245091227700226941127573627280 495738108967504018369868368450725799364729060762996941380475654823728997180326802474420629269124859052181004459842150591120249441341728531478105803603371077309182869314710171111683916581726889419 758716582152112822951848847看看mpmath

导入mpmath

mpmath.mp.dps=1000

打印mpmath.sqrt2.0

1.414213562373095048801688724209698078856569671875376948073176679737990732474662107038850387534327641572735013846230091229702492483605585077212644121497099358331412266592750559275579995050127820 605714701095599716059702745345968620147285174186408891986095523292304843087143214508397626036279952514079896872533965463318088296406206152583523950547457502877599617298355752203375318570113543746 034084988471603868999706990048150305440277903164542478230684929369186215805784631115966687130130156185689872372352885092648612494977154218334204285686060146824720771435854874155657069677653720226 485447015858801620758474922657226002085584466521458398893944370926591800311388246468157082630100594858704003186480342194897278290641045072636881313739855256117322040245091227700226941127573627280 495738108967504018369868368450725799364729060762996941380475654823728997180326802474420629269124859052181004459842150591120249441341728531478105803603371077309182869314710171111683916581726889419 758716582152112822951848847

>>> from decimal import *
>>> getcontext().prec = 100
>>> Decimal(2).sqrt()
Decimal('1.414213562373095048801688724209698078569671875376948073176679737990732478462107038850387534327641573')
>>> getcontext().prec = 1000
>>> Decimal(2).sqrt()
Decimal('1.4142135623730950488016887242096980785696718753769480731766797379907324784621070388503875343276415727350138462309122970249248360558507372126
441214970999358314132226659275055927557999505011527820605714701095599716059702745345968620147285174186408891986095523292304843087143214508397626036279
952514079896872533965463318088296406206152583523950547457502877599617298355752203375318570113543746034084988471603868999706990048150305440277903164542
478230684929369186215805784631115966687130130156185689872372352885092648612494977154218334204285686060146824720771435854874155657069677653720226485447
015858801620758474922657226002085584466521458398893944370926591800311388246468157082630100594858704003186480342194897278290641045072636881313739855256
117322040245091227700226941127573627280495738108967504018369868368450725799364729060762996941380475654823728997180326802474420629269124859052181004459
84215059112024944134172853147810580360337107730918286931471017111168391658172688941975871658215212822951848847')