python-4 类型转换

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/L1558198727/article/details/82688136

隐性类型转换

>>> 123+1.1232
124.1232

>>> 123+True
124

>>> 123+False
123

显性类型转换


>>> int(1.23)
1
>>> float(1)
1.0

乘方运算
int范围大于float
>>> float(9999 ** 9999)
Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    float(9999 ** 9999)
OverflowError: int too large to convert to float
>>> 

猜你喜欢

转载自blog.csdn.net/L1558198727/article/details/82688136