栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

PytzUsageWarning: The normalize method is no longer necessary

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

PytzUsageWarning: The normalize method is no longer necessary

PytzUsageWarning: The normalize method is no longer necessary

在Python中使用apscheduler进行定时任务,启动定时脚本时抛出错误PytzUsageWarning: The normalize method is no longer necessary。

原代码
from apscheduler.schedulers.blocking import BlockingScheduler


def crawler():
	"""爬虫任务"""
	pass


def main():
    """主函数"""
    # 创建定时对象
    scheduler = BlockingScheduler()

    # 定义任务
    scheduler.add_job(crawler, 'cron', day_of_week='tue', hour=8, minute=00)

    # 启动任务
    print("+++ +++ +++ 启动 +++ +++ +++")
    scheduler.start()


if __name__ == '__main__':
    main()

**

执行报错
C:SmartTV>python SmartTv.py
C:UsersyangAppDataLocalProgramsPythonPython310libsite-packagesapschedulerutil.py:95: PytzUsageWarning: The zone attribute is specific to pytz's interface; please migrate to a new time zone provider. For more details on how to do so, see https://pytz-deprecation-shim.readthedocs.io/en/latest/migration.html
  if obj.zone == 'local':
+++ +++ +++ 启动 +++ +++ +++
C:UsersyangAppDataLocalProgramsPythonPython310libsite-packagesapschedulertriggerscron__init__.py:146: PytzUsageWarning: The normalize method is no longer necessary, as this time zone supports the fold attribute (PEP 495). For more details on migrating to a PEP 495-compliant implementation, see https://pytz-deprecation-shim.readthedocs.io/en/latest/migration.html
  return self.timezone.normalize(dateval + difference), fieldnum
C:UsersyangAppDataLocalProgramsPythonPython310libsite-packagesapschedulertriggerscron__init__.py:159: PytzUsageWarning: The localize method is no longer necessary, as this time zone supports the fold attribute (PEP 495). For more details on migrating to a PEP 495-compliant implementation, see https://pytz-deprecation-shim.readthedocs.io/en/latest/migration.html
  return self.timezone.localize(datetime(**values))
修改之后的代码
from apscheduler.schedulers.blocking import BlockingScheduler


def crawler():
	"""爬虫任务"""
	pass


def main():
    """主函数"""
    
    # 创建定时对象
    scheduler = BlockingScheduler(timezone="Asia/Shanghai")

    # 定义任务
    scheduler.add_job(crawler, 'cron', day_of_week='tue', hour=8, minute=00)

    # 启动任务
    print("+++ +++ +++ 启动 +++ +++ +++")
    scheduler.start()


if __name__ == '__main__':
    main()
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/674488.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号