向列表中添加元素
问题描述
出现错误:AttributeError: ‘tuple’ object has no attribute ‘append’
TEXT = ()
#表头
for th in table.select('th'):
header = th.text
TEXT.append(header)
print(TEXT)
原因分析:
设置TEXT空白列表时写错了,应该写成TEXT = []
解决方案:
TEXT = ()修改为TEXT = []

向列表中添加元素
出现错误:AttributeError: ‘tuple’ object has no attribute ‘append’
TEXT = ()
#表头
for th in table.select('th'):
header = th.text
TEXT.append(header)
print(TEXT)
设置TEXT空白列表时写错了,应该写成TEXT = []
TEXT = ()修改为TEXT = []