# (i.bit_length()) 求数值二进制最小的位数 i = 100 print(i.bit_length()) # bool Ture False # int ----> str i = 1 s = str(i) # str ---> int s = '123' i = int(s) # int ----> bool 0为False 非0为True i = 3 b = bool(i) print(b) # bool ----> int True 为 1 False 为 0 # str ----> bool # s = '' ---> False 字符串为空就是False # s = '0' ---> True 字符串非空就是True 's' if 's': print('空s值') else: pass print('--------------------') 1 if 1: print('空1值') else: pass