Python 'datetime.datetime' object is unsubscriptable
Posted
by Robert
on Stack Overflow
See other posts from Stack Overflow
or by Robert
Published on 2010-03-18T22:25:02Z
Indexed on
2010/03/18
22:41 UTC
Read the original article
Hit count: 572
python
First, I am NOT a python developer. I am trying to fix an issue within a python script that is being executed from the command line. This script was written by someone who is no longer around, and no longer willing to help with issues.
This is python 2.5, and for the moment it cannot be upgraded. Here are the lines of code in question:
start_time = datetime.strptime(str(paf.Start),"%Y-%m-%d %H:%M:%S")
dict_start = datetime(*start_time[:6])
end_time = datetime.strptime(str(paf.End),"%Y-%m-%d %H:%M:%S")
dict_end = datetime(*end_time[:6])
When this code is ran, it generates an error with the description: 'datetime.datetime' object is unsubscriptable.
This is the import statement:
from datetime import datetime
I have a feeling that this is something simple, but not being my native language and Google not yielding any valuable results, I am stuck. I have tried a couple of different import methods, yielding different errors, but all with these statements. Any help on this would be greatly appreciated.
© Stack Overflow or respective owner