获取自上电以来的 linux 时间

Getting the linux time since power on

我有

time = os.popen("tuptime").readline()

输出应该是这样的:

System startups:        1   since   21:32:26 01.05.2020
System shutdowns:       0 ok   -   0 bad
System uptime:          100.0%   -   1 day, 16 hours, 49 minutes, 41 seconds
System downtime:        0.0%   -   0 seconds
System life:            1 day, 16 hours, 49 minutes, 41 seconds

Largest uptime:         1 day, 16 hours, 49 minutes, 41 seconds   from   21:32:26 01.05.2020
Shortest uptime:        1 day, 16 hours, 49 minutes, 41 seconds   from   21:32:26 01.05.2020
Average uptime:         1 day, 16 hours, 49 minutes, 41 seconds

Largest downtime:       0 seconds
Shortest downtime:      0 seconds
Average downtime:       0 seconds

Current uptime:         1 day, 16 hours, 49 minutes, 41 seconds   since   21:32:26 01.05.2020

如何获取并打印出 "System life"?

您可以在 cmd 中使用 "tuptime| grep -i 'system life'" 而不是 "tuptime"