网络编程
位置:首页>> 网络编程>> Python编程>> Python3中的最大整数和最大浮点数实例

Python3中的最大整数和最大浮点数实例

作者:Lavi_qq_2910138025  发布时间:2021-04-05 01:37:16 

标签:Python3,最大,整数,浮点数

Python中的最大整数

Python中可以通过sys模块来得到int的最大值. python2中使用的方法是


import sys
max = sys.maxint
print (max)

python3中使用的方法是:


import sys
max = sys.maxsize
print (max)

Python中获得最大浮点数

方法一:使用sys模块


>>> import sys
>>> sys.float_info
sys.floatinfo(max=1.7976931348623157e+308, max_exp=1024, max_10_exp=308, min=2.2
250738585072014e-308, min_exp=-1021, min_10_exp=-307, dig=15, mant_dig=53, epsil
on=2.2204460492503131e-16, radix=2, rounds=1)
>>> sys.float_info.max
1.7976931348623157e+308

方法二:使用float函数


>>> infinity = float("inf")
>>> infinity
inf
>>> infinity / 10000
inf

来源:https://blog.csdn.net/liuweiyuxiang/article/details/80590235

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com