这是我的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
Run Code Online (Sandbox Code Playgroud)
当我试图运行该date功能时:
tr = Transaction('AAPL', 600, '2013-10-25')
print tr.date
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
self.date = datetime.strptime(self.d, "%Y-%m-%d")
AttributeError: 'module' object has no attribute 'strptime'
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?