代码拉取完成,页面将自动刷新
#!/usr/bin/python3
"""万年历"""
import sys
import datetime
def main():
"""获取每月1号是星期几"""
if len(sys.argv) == 3:
month = int(sys.argv[1])
year = int(sys.argv[2])
else:
curr_date = datetime.datetime.now()
month = curr_date.month
year = curr_date.year
century = year//100
year1 = year if month >= 3 else year-1
month1 = month if month >= 3 else month+12
year1 = year1%100
week = year1 + year1//4+ century//4 - 2*century + 26*(month1+1)//10
day_week = week%7
print(day_week, year1, month1, century)
moon = [
"", "January", "February", "March", "April", "May", "June", "July", "August",
"September", "October", "November", "December"
]
day1 = 31 if month not in [4, 6, 9, 11] and month != 2 else 30
day2 = 28 if year / 4 == 0 and year / 100 != 0 else 29
days = day2 if month == 2 else day1
print(f'{moon[month]} {year}'.center(20))
print("Su", "Tu", "We", "Th", "Fr", "Sa", "Wo")
print(' '*(day_week), end='')
for day in range(1, days+1):
print(str(day).rjust(2), end=' ')
day_week += 1
if day_week == 7:
day_week = 0
print()
print()
if __name__ == '__main__':
main()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。