05 数据类型转换

print(str(3))           #int-->str      3
print(int('1234'))     #str-->int       1234
print(bool(3))          #int-->bool     True
print(bool(-2))         #               True
print(bool(0))          #               False
print(int(True))        #bool-->int     1
print(bool(''))         #str-->bool     False
print(bool(' '))        #               True 非空为真

猜你喜欢

转载自www.cnblogs.com/bydzxzy/p/9614677.html