Saturday, March 23, 2019

dateutil

I would like to share how to used date related library .

First please install datautil related package by pip.


pip install python-dateutil
 Chaged format from XX/XX/XXX to XXXXXX using strftim

from datetime import datetime
d = "2018/01/02"
print(datetime.strftime(datetime.strptime(d, '%Y/%m/%d'), '%Y%m%d'))
Output: 
20180102

from datetime import datetime
d = "2018/01/02"
print(datetime.strftime(datetime.strptime(d, '%Y/%m/%d'), '%Y%m%d
Output: 
Mon Feb 15 10

No comments:

Post a Comment