Reputation: 431
I want to convert datetime string to datetime format. I already tried with datetime.strptime but this code doesn't covert to datetime format.
In python 3.0 version, I tried strptime and parse to covert to datetime format.
nut_time_ = (nut_unique_date + ' ' + nut_unique_time)
print(nut_time)
nut_time_ = datetime.datetime.strptime(nut_time_, '%Y-%m-%d %H:%M:%S')
print(nut_time)
The format that I want to get is : datetime.datetime(2013, 1, 6, 20, 33, 42)
But the actual results is : 2013-01-06 20:33:42
Upvotes: 0
Views: 185
Reputation: 7211
Quick answer:
print(repr(nut_time_))
The issue is whether you want to print(str(nut_time_))
or the repr
version. The former is what you get. So nothing wrong with you. The latter is what you usually see in the Python REPL. If you use print()
function to print some stuff, by default it will give you the str representation.
Upvotes: 2