Quantcast
Channel: Python datetime timestamp issue - Stack Overflow
Browsing index pages (3 articles)

Python datetime timestamp issue

I was trying to create a dictionary with time stamp as the key.the code is :>>> stamp = datetime.datetime(2012, 4, 12, 12, 26, int('13'))>>> new_dict = {}>>> new_dict[stamp]...

View Article


Answer by Lev Levitsky for Python datetime timestamp issue

Because stamp is a datetime.datetime object. When you print it, a string representing this object is printed. If you want a str key, trynew_dict[str(stamp)] = 'one'

View Article


Answer by Luper Rouch for Python datetime timestamp issue

'2012-04-12 12:26:13' is a string, and stamp in your example is a datetime.datetime object.You can use datetime objects directly as keys in a dictionnary, as stated in the documentation (two identical...

View Article
Browsing index pages (3 articles)


Latest Images