python - Python Texttable

标签 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

最佳答案

您将元素列表分配给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/

相关文章:

mysql - 这个 SELECT FROM WHERE ORDER BY mysql 语法有什么问题?

python - 是否可以查看 urllib2 响应中的数据?

python - 如何在缩略图库中制作可点击的 kivy 图像

python - Pandas 中分组值的堆叠直方图

python - 在 python 3 中使用分号在单行中定义 lambda 函数

尝试评估表达式时 Python eval() 语法错误

python - 在 Django 中显示/渲染静态图像的简单 View

python - 如何在Python中正确调用带有可选参数的函数

php - for()中的mysql_fetch_array函数出现错误

oracle - ORA-00904 SQLSyntaxErrorException与可执行查询