datetime
Ausführungsdatum
# yyyymmdd
yyyymmdd = datetime.date.today().strftime('%Y%m%d')
print(yyyymmdd)
# yyyy/mm/dd
yyyymmdd = datetime.date.today().strftime('%Y/%m/%d')
print(yyyymmdd)
# yyyy-mm-dd
yyyymmdd = datetime.date.today().strftime('%Y-%m-%d')
print(yyyymmdd)
Ergebnis
20200917
2020/09/17
2020-09-17
yyyymmddhhmmss
Ausführungsdatum
yyyymmdd_hms = datetime.date.now().strftime('%Y%m%d%H%M%S')
print(yyyymmdd_hms)
Ergebnis
20200917155026
Verwenden Sie strftime ()
Klicken Sie hier für den Formatcode [Formatcode für strftime () und strptime ()]
(https://docs.python.org/ja/3/library/datetime.html#strftime-and-strptime-format-codes)
Recommended Posts