我正在 python 2.7.3 中为 smartctl 编写一个包装器...
我花了很长时间试图解决如何解析smartctlLinux 中程序的输出(具体来说是 Ubuntu x64)
我正在smartctl -l selftest /dev/sdx通过子进程运行并将输出抓取到变量中
该变量被分解为一个列表,然后我从输出中删除无用的标题数据和空行。
现在,我留下了一个字符串列表,这太棒了!
数据是表格形式的,我想将其解析为充满列表的 dict() (我认为这是通过阅读文档在 Python 中表示表格数据的正确方法)
以下是数据示例:
Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error
# 1 Short offline Completed without error 00% 44796 -
# 2 Short offline Completed without error 00% 44796 -
# 3 Short offline Completed without error 00% 44796 -
# 4 Short offline Completed without error 00% 44796 -
# 5 Short offline Completed without error 00% …Run Code Online (Sandbox Code Playgroud)