現在の年と月を datetime で取得する必要があります。
私はこれを使用します:
datem = datetime.today().strftime("%Y-%m")
datem = datetime.strptime(datem, "%Y-%m")
他に方法はあるでしょうか?
ベストアンサー1
次の解決策を試してください:
from datetime import datetime
current_second = datetime.now().second
current_minute = datetime.now().minute
current_hour = datetime.now().hour
current_day = datetime.now().day
current_month = datetime.now().month
current_year = datetime.now().year