from datetime import datetime\n\ngiven_time = datetime.strptime("2023-08-14 06:50:41.319947+00", "%Y-%m-%d %H:%M:%S.%f%z")\ncurrent_time = datetime.now(given_time.tzinfo)\n\ntime_difference = current_time - given_time\nprint("time:", time_difference)\n\nraise ValueError("time data %r does not match format %r" % ('2023-08-14 06:50:41.319947+00', '%Y-%m-%d %H:%M:%S.%f%z'))

Python 计算时间差 - 使用 datetime 模块

原文地址: https://www.cveoy.top/t/topic/qsSM 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录