Do anyone know how to convert a text file date format to specific format.
For example i have a text file and the file is 2018/01/02, and i wants to convert in into 20180102.
In hoilday.txt have many date in this format( year/m/d), and i wants to change to ymd format.
For example i have a text file and the file is 2018/01/02, and i wants to convert in into 20180102.
In hoilday.txt have many date in this format( year/m/d), and i wants to change to ymd format.
import datetime as dt with open('holiday.txt') as f, open('new.txt', 'w') as f_out: for line in f: line = line.strip() f_out.write(dt.strftime('%d%m%Y'))