【发布时间】:2013-10-29 02:09:11
【问题描述】:
这是我的Transaction 课程:
class Transaction(object):
def __init__(self, company, num, price, date, is_buy):
self.company = company
self.num = num
self.price = price
self.date = datetime.strptime(date, "%Y-%m-%d")
self.is_buy = is_buy
当我尝试运行date 函数时:
tr = Transaction('AAPL', 600, '2013-10-25')
print tr.date
我收到以下错误:
self.date = datetime.strptime(self.d, "%Y-%m-%d")
AttributeError: 'module' object has no attribute 'strptime'
我该如何解决这个问题?
【问题讨论】:
-
from datetime import datetime -
我今天遇到了同样的问题。这是 Python 2 库中的一个已知线程错误。它不会被修复。解决方案:
import _strptime在此处阅读更多内容:stackoverflow.com/questions/32245560/… 我们是否将其标记为骗子?
标签: python class python-2.7