看板 [ Python ]
討論串[問題] 迴圈問題
共 7 篇文章
首頁
上一頁
1
2
下一頁
尾頁

推噓2(2推 0噓 6→)留言8則,0人參與, 2年前最新作者skyleona (多益爆了!)時間2年前 (2022/02/20 23:43), 2年前編輯資訊
3
0
0
內容預覽:
大家好,最近剛學python有迴圈問題想請教. 用迴圈方式去依序將年份及月份列出來,月份設定為1時,輸出正常:. for year in range(2000,2020):. for month in range(1,13):. print(str(year) + '/' + str(month)
(還有133個字)

推噓2(2推 0噓 1→)留言3則,0人參與, 2年前最新作者TuCH (謬客)時間2年前 (2022/02/21 10:53), 編輯資訊
0
0
0
內容預覽:
參考一下. 錯誤處理就不寫了. # 輸入資料. my_date = input('Please input daterange ex: 2018/6~2019/12'). # 解析資料. start_date, end_date = my_date.split('~'). start_year, s
(還有589個字)

推噓1(1推 0噓 1→)留言2則,0人參與, 2年前最新作者lycantrope (阿寬)時間2年前 (2022/02/21 15:47), 編輯資訊
0
0
0
內容預覽:
# 輸入資料. input_date = input('Please input date range(ex: 2018/6~2019/12): '). # 解析資料. start_date, end_date = input_date.split('~'). start_year, start_m
(還有286個字)

推噓5(5推 0噓 3→)留言8則,0人參與, 2年前最新作者poototo (poototo)時間2年前 (2022/02/21 20:50), 編輯資訊
0
0
0
內容預覽:
也可比較tuple來篩選. =================================. s = 2018, 6. e = 2019, 12. #. for y in range(2017, 2020):. for m in range(1, 13):. if s <= (y, m) <=

推噓1(1推 0噓 0→)留言1則,0人參與, 2年前最新作者numpy (那麼拍)時間2年前 (2022/02/23 22:36), 2年前編輯資訊
0
0
0
內容預覽:
雖然有很多答案了,還是想提供一個另類做法. 小缺點是需要用到 datetime, dateutil. 但可以更原生地處理日期. from datetime import datetime, timedelta. from dateutil.relativedelta import relatived
(還有202個字)
首頁
上一頁
1
2
下一頁
尾頁