如何在python中获取当前月份?

问题描述 投票:1回答:2

在下面的给定代码中,我想获取当前月份(如果今天运行,则为十月),而不是monthpage中的current_month =“ file / monthly / current_month”

如何完成?

    def CurrentMonth(self):

        monthpage = "file/monthly/current_month"
        page = Page
        old_text = page.get(get_redirect=True)
python python-3.x datetime
2个回答
0
投票

简单。使用日期时间库!

import datetime
mydate = datetime.datetime.now()
mydate.strftime("%B")
© www.soinside.com 2019 - 2024. All rights reserved.