I used following line to transfer my date string but it gave me an error.
print datetime.datetime.strptime(arg, '%d %b %Y').date().strftime("%B %d, %Y")
ValueError: time data '28 JUL 1795' does not match format '%B %d %Y'
I used following line to transfer my date string but it gave me an error.
print datetime.datetime.strptime(arg, '%d %b %Y').date().strftime("%B %d, %Y")
ValueError: time data '28 JUL 1795' does not match format '%B %d %Y'
This behaviour is not reproduceable. The following works as intended:
>>> datetime.datetime.strptime('28 JUL 1995', '%d %b %Y').date().strftime('%B %d, %Y')
'July 28, 1995'
Maybe your input string is not what you expect it to be.
Use like this
time.strptime("28 JUL 1795", "%d %b %y")
heres a link to strptime method which will convert it for you http://docs.python.org/2/library/time.html#time.strptime
heres a link to a similiar question Converting string into datetime