我必须在日期时间中有当前的年份和月份。
我用这个:
datem = datetime.today().strftime("%Y-%m")
datem = datetime.strptime(datem, "%Y-%m")
还有其他方法吗?
最佳答案
试试这个解决方案:
from datetime import datetime
currentSecond= datetime.now().second
currentMinute = datetime.now().minute
currentHour = datetime.now().hour
currentDay = datetime.now().day
currentMonth = datetime.now().month
currentYear = datetime.now().year
关于python - Python中的日期时间当前年份和月份,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28189442/