如何使用 Python 獲取星期一?


你可以使用日曆模組用 Python 獲取星期日。日曆模組有一個特殊函式 firstweekday(),該函式返回當前設定中每週開始的星期幾。

示例

import calendar
print(calendar.firstweekday())
calendar.setfirstweekday(2)
print(calendar.firstweekday())

輸出

該輸出將返回 −

6
2

更新時間: 2020-06-12

2000+ 瀏覽

開啟你的職業生涯

完成課程並獲得認證

開始學習
廣告
© . All rights reserved.