LoginSignup
1
2

More than 5 years have passed since last update.

Pythonで2017年のプレミアムフライデー一覧を出力する

Last updated at Posted at 2017-02-26

(わーい!初投稿たーのしー!)

プレミアムフライデー初日より遅れての投稿です...

2017年の各月最終の金曜一覧出力

lastfri.py
import calendar

def Last_FridayList(year):
 for month in range(1, 13):
  lastfri = max(week[calendar.FRIDAY]
   for week in calendar.monthcalendar(year, month))
  print('{:4d}-{:02d}-{:02d}'.format(year, month, lastfri))
Last_FridayList(2017)

これで、
2017-01-27
2017-02-24
2017-03-31
2017-04-28
2017-05-26
2017-06-30
2017-07-28
2017-08-25
2017-09-29
2017-10-27
2017-11-24
2017-12-29
と標準出力できます。

1
2
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
1
2