1
votes
import datetime

print datetime.strptime("00", "%y").year

I would like to be able to pass "00" into datetime.strptime and receive "2000" as an output. However, When I run code, I keep getting this error: AttributeError: 'module' object has no attribute 'strptime'

1

1 Answers

3
votes

strptime is not found directly at the level of the datetime module. It is a classmethod of the datetime type inside the datetime module, so:

print datetime.datetime.strptime("00", "%y").year