import time from datetime import datetime tt = time.strftime("%Y%m%d_%H%M%S") print(tt) time.sleep(5) print(tt)