Đây là Transaction
lớp học của tôi:AttributeError: đối tượng 'module' không có thuộc tính 'strptime'
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
Và khi tôi đang cố gắng để chạy date
chức năng:
tr = Transaction('AAPL', 600, '2013-10-25')
print tr.date
Tôi nhận được lỗi sau:
self.date = datetime.strptime(self.d, "%Y-%m-%d")
AttributeError: 'module' object has no attribute 'strptime'
Làm cách nào để khắc phục điều đó?
'từ datetime nhập khẩu datetime' –