parsing text from "ethtool" command
Ian Kelly
ian.g.kelly at gmail.com
Tue Nov 1 19:35:10 EDT 2011
On Tue, Nov 1, 2011 at 5:19 PM, Miki Tebeka <miki.tebeka at gmail.com> wrote:
> In my box, there are some spaces (tabs?) before "Speed". IMO re.search("Speed", line) will be a more robust.
Or simply:
if "Speed" in line:
There is no need for a regular expression here. This would also work
and be a bit more discriminating:
if line.strip().startswith("Speed")
BTW, to the OP, note that your condition (line[0:6] == "Speed") cannot
match, since line[0:6] is a 6-character slice, while "Speed" is a
5-character string.
Cheers,
Ian
More information about the Python-list
mailing list