0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

jinja2やPythonで頻繁に使う日本語曜日の便利な書き方

0
Posted at

みんながよくやるであろう日付の表示
一般的にstrftimeを使うと思う

date_value.strftime("%Y年 %m月 %d日 (%a)")

しかし曜日を日本語で1文字表記したい場面ってとても多いのではないだろうか
知っていればそんなことかよって感じだけど意外と面倒なことをやっている人を見かけるのでメモ

date_value.strftime("%Y年 %m月 %d日 (") + "月火水木金土日"[date_value.weekday()] + ")"

jinja2でよくやるのはこれ

<span class="wd{{date_value.weekday()}}">{{ "月火水木金土日"[date_value.weekday()] }}</span>
0
0
0

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?