4
2

More than 3 years have passed since last update.

PythonでYYYYMMDD形式の文字列を取得する

Posted at

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() の書式コード

なんでこんな単純な記事書いたの?

ググって出てきたコードがコピペで動かないやつばっかでイラっとしたから。

4
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2