-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathk013.py
35 lines (25 loc) · 839 Bytes
/
k013.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#! /usr/bin/python3
# coding: utf-8
import calendar
def main():
date = input("日時(YYYY/MM) : ").split("/")
year = int(date[0])
month = int(date[1])
print(MyCalendar(calendar.SUNDAY).formatmonth(year, month))
class MyCalendar(calendar.TextCalendar):
def formatmonthname(self, theyear, themonth, width, withyear=True):
s = str(themonth) + "月"
if withyear:
s = "%r年 %s" % (theyear, s)
return s.center(width)
def formatweekday(self, day, width):
"""
Returns a formatted week day name.
"""
# width -= 1
if width >= 9:
names = ["月", "火", "水", "木", "金", "土", "日"]
else:
names = ["月", "火", "水", "木", "金", "土", "日"]
return names[day][:width].center(width)
main()