如何在IronPython中使用datetime模块?
我正在尝试把我的一个程序从CPython解释器移植到IronPython。现在让我感到困惑的部分是我使用了datetime模块里的datetime类。当我尝试使用strptime函数时,出现了问题。
» from datetime import datetime
» dt = datetime.strptime("21/11/06 16:30", "%d/%m/%y %H:%M")
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: 'type' object has no attribute 'strptime'
»
在IronPython中,有什么特别需要注意的地方,让datetime变得不一样吗?
1 个回答
2
没有特别的原因,datetime.strptime
这个功能在 IronPython 2.7.1 之前是没有的。如果你正在使用一个旧版本,可以用 time.strptime
来代替。