用Python实现指定日期的日历

简介: 用Python实现指定日期的日历

以下代码用于生成指定日期的日历:

以下代码用于生成指定日期的日历:

实例(Python 3.0+)

# Filename : test.py
# author by : www.dida100.com
# 引入日历模块
import calendar
# 输入指定年月
yy = int(input("输入年份: "))
mm = int(input("输入月份: "))
# 显示日历
print(calendar.month(yy,mm))

尝试一下

 

执行以上代码输出结果为:

输入年份: 2015

输入月份: 6

    June 2015

Mo Tu We Th Fr Sa Su

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

 

相关文章
|
2天前
|
Python
「Python系列」Python 日期和时间
Python 提供了多个内置模块来处理日期和时间,其中最常用的是 `datetime` 模块。这个模块提供了类来操作日期、时间、日期和时间间隔。
31 0
|
2天前
|
Unix 数据处理 Python
Python中日期时间的处理
Python中日期时间的处理
27 0
|
2天前
|
Python
Python TK实现的日历
Python TK实现的日历
28 0
|
2天前
|
编译器 Python
Python关于日期的记录
Python关于日期的记录
18 0
|
2天前
|
Python
python获取当前日期
python获取当前日期
31 1
|
2天前
|
BI Python
python报表自动化系列 - 获取某月日历并以列表形式返回(公历)
python报表自动化系列 - 获取某月日历并以列表形式返回(公历)
25 1
|
2天前
|
安全 Python
Python如何使用datetime模块进行日期和时间的操作
Python如何使用datetime模块进行日期和时间的操作
29 1
|
2天前
|
存储 监控 Python
python 日期字符串转换为指定格式的日期
python 日期字符串转换为指定格式的日期
18 3
|
2天前
|
机器学习/深度学习 Python
python自定义日历库,与对应calendar库函数功能基本一致
python自定义日历库,与对应calendar库函数功能基本一致
43 0
|
2天前
|
定位技术 数据处理 Python
Python中的`datetime`模块:深入探索日期和时间操作
在Python中,处理日期和时间是一项常见的任务。`datetime`模块提供了丰富的类和方法,使得我们可以轻松地创建、解析、操作格式化日期和时间对象。这个模块在数据处理、时间戳转换、定时任务等多个领域都有着广泛的应用。