📜  python 将日期设置为 1 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:26.945000             🧑  作者: Mango

代码示例1
from datetime import datetime

your_date = datetime.strptime('26 June 2021', '%d %b %Y')
# Using the .replace() method:
newdatetime = your_date.replace(day=1)
# 2021-06-01 00:00:00