15
我想从Python获取UTC格式文件的修改日期。以下代码返回Linux配置时区(GMT-5)中的日期。我需要它在UTC。或者我如何获得os配置的时区来使用pytz转换它?如何从Python获取UTC格式的文件修改日期
$ python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from datetime import datetime
>>> import os
>>> dt=os.path.getmtime('/home/user/.bashrc')
>>> datetime.datetime.fromtimestamp(dt)
datetime(2012, 5, 30, 21, 18, 10)
感谢