Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Prettytable 0.7.2 HTML表格不工作_Python_Python 2.7 - Fatal编程技术网

Python Prettytable 0.7.2 HTML表格不工作

Python Prettytable 0.7.2 HTML表格不工作,python,python-2.7,Python,Python 2.7,因此,我试图让Prettytable 0.7.2使用HTML表。我就是不能让它工作。我正在使用以下工具: from prettytable import from_html html = "<table><tr><th>h1</th></tr><tr><td>v1</td></tr></table>" table = from_html(html) print (table)

因此,我试图让Prettytable 0.7.2使用HTML表。我就是不能让它工作。我正在使用以下工具:

from prettytable import from_html
html = "<table><tr><th>h1</th></tr><tr><td>v1</td></tr></table>"
table = from_html(html)
print (table)
从prettytable从html导入
html=“h1v1”
表格=来自html(html)
打印(表格)
其结果是:

[<prettytable.PrettyTable object at 0x90556ec>]
[]

我可以使用其他方法使表工作,但我似乎无法处理HTML表方法。我不确定我是做错了什么还是错过了什么。如果有人能解释一下这个问题,我们将不胜感激。

问题是,
table
不是一个漂亮的对象,但是

调用
from_html
函数将返回一个列表,该列表包含html字符串中遇到的每个
table
标记的一个PrettyTable

您要执行以下操作:

print table[0]
返回:

+----+
| h1 |
+----+
| v1 |
+----+