uptime for Win XP?

Fredrik Lundh fredrik at pythonware.com
Sun Dec 12 10:23:28 CET 2004


Esmail Bonakdarian wrote:

> Is there a way to display how long a Win XP system has been up?
> Somewhat analogous to the *nix uptime command.

ugly, somewhat slow, and possibly locale dependent:

import os, re

def uptime():
    return re.search(
        "System Up Time:\s*(.+)", os.popen("systeminfo").read()
        ).group(1)

print uptime()

</F> 






More information about the Python-list mailing list