我使用控制台在Heroku上运行以下代码:
~ $ python
Python 3.6.6 (default, Aug 1 2018, 21:10:15)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import datetime
>>> datetime.datetime.fromisoformat("2015-06-06T17:23:54+10:00")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: type object 'datetime.datetime' has no attribute 'fromisoformat'
>>>
在Python 3.7.0下的Mac上,这可以很好地工作。
如何访问在Heroku下运行的“fromisoformat”?
最佳答案
愚蠢的我。 “fromisofomat”仅在Python3.7.0中出现。 heroku的默认值为Python3.6.6。使用python-3.7.0添加了runtime.txt,现在一切正常。
希望这对其他人有帮助。
关于python-3.x - heroku python datetime不包括fromisoformat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53439227/