我正在尝试为使用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
最佳答案
您将元素列表分配给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)
关于python - Python Texttable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42376672/