2
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

posted at

updated at

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

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

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

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
と標準出力できます。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Sign upLogin
2
Help us understand the problem. What are the problem?