[Tutor] python3 equivalent of coreutils stat command

street.sweeper at mailworks.org street.sweeper at mailworks.org
Sat Jun 14 23:06:14 CEST 2014


With the stat command in GNU coreutils, I can get a file's
modification time, with timezone offset.  For example, the
output of "stat -c %y *" looks like

    2014-02-03 14:48:17.000000000 -0200
    2014-05-29 19:00:05.000000000 -0100

What I want to do is get the mtime in ISO8601 format, and I've
gotten close with os.path.getmtime and os.stat, for example
2014-02-03T14:48:17.  But, no timezone offset.  coreutils stat
can get it, so it must be recorded by the filesystem (ext4 in
this case).  What do I need to do in python to include this
piece of information?

Thanks


More information about the Tutor mailing list