【发布时间】:2015-11-26 16:17:50
【问题描述】:
我有一个 python 脚本,它使用 mechanize 从网页中获取数据。这工作正常,但我已经完成了一项黑客工作,然后使用 bash 过滤我正在寻找的文本。我现在需要在主 python 脚本中执行此操作,因为我需要使用输出值。
response = br.submit()
print response.read()
这会打印出我然后用 bash 操作的响应
| grep usedData | cut -d '"' -f2 | sed 's/\<GB used\>//g'`
如何在 python 中完成这一切?
bash 脚本的输出将是一个数字(例如 123.45)
输入:
<tr><th>Current Data Usage: </th><td>221.59GB</td></tr>
Output: 221.59
【问题讨论】:
-
请给出一些问题的输入/输出示例。
-
你可以通过标准输入参数使用 python 管道; stackoverflow.com/questions/9655841/…
标签: python