Project scenario:
Add element to list
Problem Description
An error occurred: AttributeError: ‘tuple’ object has no attribute ‘append’
TEXT = ()
#表头
for th in table.select('th'):
header = th.text
TEXT.append(header)
print(TEXT)
Cause Analysis:
tuples cannot be added, indicating that TEXT is a tuple type.
Looking forward, I found that I made a mistake when setting the TEXT blank list. It should be written as TEXT = []
solution:
TEXT = () changed to TEXT = []