首页 > 编程 > Python > 正文

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

2019-11-25 12:27:47
字体:
来源:转载
供稿:网友

Python中的最大整数

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

import sysmax = sys.maxintprint (max)

python3中使用的方法是:

import sysmax = sys.maxsizeprint (max)

Python中获得最大浮点数

方法一:使用sys模块

>>> import sys>>> sys.float_infosys.floatinfo(max=1.7976931348623157e+308, max_exp=1024, max_10_exp=308, min=2.2250738585072014e-308, min_exp=-1021, min_10_exp=-307, dig=15, mant_dig=53, epsilon=2.2204460492503131e-16, radix=2, rounds=1)>>> sys.float_info.max1.7976931348623157e+308

方法二:使用float函数

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

以上这篇Python3中的最大整数和最大浮点数实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持武林网。

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表