我正在尝试使用texttable为练习构建一个表。
tab.add_row(row) = ["Match1", Team1_matches[1], Team2_matches[1], max(Team1_matches[1],Team2_matches[1])]
我得到了这个:
tab.add_rows(row) = ["Match1", Team1_matches[1], Team2_matches[1]]
SyntaxError: can't assign to function call
答案 0 :(得分:0)
您已将元素列表分配给tab.add_row(row)
,这就是您获得SyntaxError
使用Texttable
的正确方法是:
# create a list with the elements and assign it to row
row = ["Match1", Team1_matches[1], Team2_matches[1], max(Team1_matches[1],Team2_matches[1])]
# insert a row into table by invoking add_row() of the TextTable object tab.
tab.add_row(row)