问题:
- pywintypes.datetime在python中不能直接使用,报错......‘pywintypes.datetime‘......相关
原因:
- pywintypes.datetime包含时区参数:"2016-04-01 17:29:25+00:00"
解决方案:
- 使用第三方库dateutil
- python方法,麻烦
In [1]: pywindt
Out[1]: pywintypes.datetime(2018, 9, 13, 14, 2, 24, tzinfo=TimeZoneInfo(‘GMT Standard Time‘, True))
In [2]: str(pywindt)
Out[2]: ‘2018-09-13 14:02:24+00:00‘
In [3]: # Conversion takes place here!
In [4]: dt = datetime.datetime.fromtimestamp(
...: timestamp=pywindt.timestamp(),
...: tz=pywindt.tzinfo
...: )
In [5]: dt
Out[5]: datetime.datetime(2018, 9, 13, 14, 2, 24, tzinfo=TimeZoneInfo(‘GMT Standard Time‘, True))
In [6]: str(dt)
Out[6]: ‘2018-09-13 14:02:24+00:00‘
str(oltime).replace(‘+00:00‘, ‘‘)
‘2020-06-21 19:50:00‘
pywintypes.datetime转化为datetime.date