datetime - How do I convert dates from "Month DD,YY" to "MM/DD/YY" in python? -
how convert april 28,2015 04/28/15 in python? can assign april = 4 not april 04. how do that?
c:> pip install python-dateutil c:> python ... >>> dateutil.parser import parse >>> print "stack overflow saved bacon on:",parse("april 28,2015").strftime("%m/%d/%y") if sure of format, of course specify exactly:
>>> import datetime >>> print datetime.datetime.strptime("%b %d,%y","april 28,2015").strftime("%m/%d/%y")
Comments
Post a Comment