【发布时间】:2020-10-10 16:29:28
【问题描述】:
我刚开始使用 Python pandas,需要一些指导。假设我有一个包含多个表的 html 文件,并且每个表由每个表的 Caption 唯一标识,即表号 135 等。
如果我希望使用唯一的标题“Table 246”来识别和读取该表,Python Pandas 如何专门读取该表而忽略其他表?我需要使用它的标题来阅读这个 Table 246,因为这个文件中表格的顺序不是固定的,它是动态的。
一直在互联网上搜索,但没有找到任何使用 Table 的标题来识别该表的解决方案。
我的 html 文件内容
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
</head>
<body>
<p>
<table border=1>
<caption align=left>Table 135</caption>
<tr bgcolor="#d4d0c8" bordercolor=black>
<th bordercolor=black>User Name</th>
<th bordercolor=black>Mobile Number</th>
</tr>
<tr bordercolor=black>
<td bordercolor=black bgcolor=white>John</td>
<td bordercolor=black bgcolor=white>1234567890</td>
</tr>
</table>
</p>
<p>
<table border=1>
<caption align=left>Table 246</caption>
<tr bgcolor="#d4d0c8" bordercolor=black>
<th bordercolor=black>Salary</th>
<th bordercolor=black>Experience</th>
</tr>
<tr bordercolor=black>
<td bordercolor=black bgcolor=white>$5000</td>
<td bordercolor=black bgcolor=white>10</td>
</tr>
</table>
</p>
</body>
</html>
【问题讨论】:
-
您是否检查过文档以阅读 pandas 中的 html 表格?因为你是这个论坛的新手(我猜)我建议首先查找以前的答案..或类似的问题..您将通过这种方式了解更多信息...或等待有人为您回答这个问题..谢谢理解!
标签: python html pandas html-table