Python——字符转换(int , bool ,str)

while True:
    pass

while 1:
    pass
    
#效果相同,后者 效果更快

s = 1
y = bool (s)
#结果为True,int只要不是0,就为真

s = 'abc'
y = bool (s)
#结果为True,str型有数值,就为真
s
while s :
    pass
#可以直接判断,这样引用,s直接是空数据,为False

猜你喜欢

转载自www.cnblogs.com/cxys85/p/9639232.html