可能会遇到这种需求:将xxxx年 补齐为 xxxx年1月1日,将xxxx年xx月 补齐为 xxxx年x月1日。
from datetime import datetime
datetime.strptime("2001年", "%Y年").strftime("%Y年%m月%日")
datetime.strptime("2001年2月", "%Y年").strftime("%Y年%m月%日")
可能会遇到这种需求:将xxxx年 补齐为 xxxx年1月1日,将xxxx年xx月 补齐为 xxxx年x月1日。
from datetime import datetime
datetime.strptime("2001年", "%Y年").strftime("%Y年%m月%日")
datetime.strptime("2001年2月", "%Y年").strftime("%Y年%m月%日")