获取当前月份数据

import datetime
# 获取当前年月日 格式为2000-01-01
today = datetime.datetime.now( )
time1 = str(today.strftime("%Y-%m-%d"))

# 获取当前月份的初始日期,例如,当前为2022-01-20,打印出来对数据 2022-01-01
today = datetime.datetime.today()
month_start = datetime.datetime(today.year, today.month, 1)
time2 = month_start.strftime("%Y-%m-%d")

你可能感兴趣的:(python,pycharm,pytest,自动化)