Ecco la mia Transaction
classe:AttributeError: oggetto 'modulo' non ha alcun attributo '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
E quando sto cercando di eseguire la funzione date
:
tr = Transaction('AAPL', 600, '2013-10-25')
print tr.date
Sono ottenendo il seguente errore:
self.date = datetime.strptime(self.d, "%Y-%m-%d")
AttributeError: 'module' object has no attribute 'strptime'
Come posso risolvere il problema?
'da datetime import DateTime' –