Python Texttable

时间:2017-02-21 19:52:14

标签: python syntax-error

我正在尝试使用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

1 个答案:

答案 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)