如何使用 Python 獲取星期一?
你可以使用日曆模組用 Python 獲取星期日。日曆模組有一個特殊函式 firstweekday(),該函式返回當前設定中每週開始的星期幾。
示例
import calendar print(calendar.firstweekday()) calendar.setfirstweekday(2) print(calendar.firstweekday())
輸出
該輸出將返回 −
6 2
廣告
你可以使用日曆模組用 Python 獲取星期日。日曆模組有一個特殊函式 firstweekday(),該函式返回當前設定中每週開始的星期幾。
import calendar print(calendar.firstweekday()) calendar.setfirstweekday(2) print(calendar.firstweekday())
該輸出將返回 −
6 2