1 Star 0 Fork 0

wdhxm52/temporary

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
wannianli.py 1.25 KB
一键复制 编辑 原始数据 按行查看 历史
wdhxm52 提交于 2019-07-17 15:57 . 添加文件
#!/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()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wdhxm52/temporary.git
git@gitee.com:wdhxm52/temporary.git
wdhxm52
temporary
temporary
master

搜索帮助