YYYYMMDD形式
import datetime
format(datetime.date.today(), '%Y%m%d') # -> '20210805'
YYYY/MM/DD形式
import datetime
format(datetime.date.today(), '%Y/%m/%d') # -> '2021/08/05'
フォーマット方法が知りたい
Pythonのドキュメントはこちら。
strftime() と strptime() の書式コード
なんでこんな単純な記事書いたの?
ググって出てきたコードがコピペで動かないやつばっかでイラっとしたから。