Python文本表

Python文本表,python,syntax-error,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

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

您已将元素列表分配给
选项卡。添加\u行(行)
,这就是您获得
语法错误的原因

正确使用
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)

您已将元素列表分配给
选项卡。添加\u行(行)
,这就是您获得
语法错误的原因

正确使用
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)