在Python中输入日期可以通过以下几种方式:
1. 使用`input()`函数接收用户输入的年月日,并将它们转换为整数存储在变量中。
year = int(input("请输入年份: "))
month = int(input("请输入月份: "))
day = int(input("请输入日期: "))
2. 使用`datetime`模块创建日期对象。
from datetime import date
my_date = date(year, month, day)
3. 使用`calendar`模块输出当前日期。
import calendar
print(calendar.month(year, month))
4. 使用`pandas`库处理日期时间数据。
import pandas as pd
applydata['apply_date'] = pd.to_datetime(applydata['apply_date']).dt.strftime('%Y-%m-%d')
5. 使用`time`模块输出当前日期时间。
import time
print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()))
请根据您的需求选择合适的方法输入日期