好吧,我知道你不能把元组附加到列表中。然而,尽管我尽了最大努力,我还是收到了这个错误。有人能告诉我我做错了什么吗?Traceback (most recent call last):
File "C:/Users/.py", line 31, in
listRow.append(convertedList)
AttributeError: 'tuple' object has no attribute 'append'
followdby是一个来自游标的字符串,它被拆分成一个列表形式。下面是游标将包含的一些示例数据。
followedBy=“0 | 1 | 2 | 40”table = [] #contains all rows (table)
row = [] #contains row
listFollowedBy = [] #contains ids
for (var1, var2, var3, followedBy) in cursor:
row = var1, var2, var3
listFollowedBy = followedBy.split("| ") #Thought split always split the data into lists
convertedList = list(listFollowedBy) #Threw this in there just to insure it was converted to a list
row.append(convertedList)
table.append(row)