# 针对网上置顶的好些文章不靠谱,我再写一篇。
# 'bool' object 中文意思布尔值对象,在Python中True和False就是布尔值。
# 布尔值是表示真(对)或假(错)。
# 问题复现如下,看见该报错是表达了布尔值即True,False不支持被dict,list,tuple 等方法做处理。
for i,j in zip([True],[False]):
print(i,j)
print(i==j)
print(str(i))
print(dict(j)) # list,tuple等操作都不支持。
True False
False
True
TypeError Traceback (most recent call last)
C:\Users\ADMINI~1\AppData\Local\Temp/ipykernel_7080/3127318733.py in
9 print(i==j)
10 print(str(i))
—> 11 print(dict(j)) # list,tuple等操作都不支持。
TypeError: ‘bool’ object is not iterable