uptime for Win XP?
Esmail Bonakdarian
ebonakDUH at hotmail.com
Sun Dec 12 20:56:53 EST 2004
Peter Hansen wrote:
>
> I believe there is, though I can't guarantee this is a
> valid approach:
>
> >>> import datetime
> >>> import os
> >>> def uptime():
> ... t = os.stat('c:/pagefile.sys').st_mtime
> ... td = datetime.datetime.now() - datetime.datetime.fromtimestamp(t)
> ... return td
> ...
> >>> print uptime()
> 12 days, 20:21:17.491000
>
> (matches results of Bengt's and Fredrik's two approaches
> two within a minute or so)
Wow .. this seems to work off-the-bat, thanks a lot!!
Esmail
More information about the Python-list
mailing list