計算當前時間是本年第幾周:
import datetime datetime.datetime.now().isocalendar() # (2020, 37, 5):當前時間是2002年第37周周五
計算指定時間是當年第幾周:
1 import datetime 2 datetime.date(2020, 10, 1).isocalendar() 3 # (2020, 40, 4):2020年10月1號是2020年第40周周4
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/5970.html
標籤:Python
上一篇:python計算年收益
