python 实现日历 源代码
时间: 2024-01-05 14:45:51 浏览: 96
基于python实现简单日历
以下是Python实现日历的源代码:
```python
import calendar
# 输入年份和月份
year = int(input("请输入年份:"))
month = int(input("请输入月份:"))
# 显示日历
print("\t\t%d年%d月" % (year, month))
print("日\t一\t二\t三\t四\t五\t六")
cal = calendar.monthcalendar(year, month)
for i in range(len(cal)):
for j in range(len(cal[i])):
if cal[i][j] == 0:
print("\t", end="")
else:
print("%d\t" % cal[i][j], end="")
print()
```
希望对您有帮助!
阅读全文