在下面的给定代码中,我想获取当前月份(如果今天运行,则为10月),而不是"current_month"
中的monthpage
。
如何完成?
"file/monthly/current_month"
def CurrentMonth(self):
monthpage = "file/monthly/current_month"
page = Page
old_text = page.get(get_redirect=True)
用实际的当前月份名称替换from datetime import datetime
now = datetime.now()
monthpage.replace('current_month',now.strftime("%B"))
变量中的"current_month"
字符串
简单。使用日期时间库!
monthpage