小编CC *_* CC的帖子

Python如何在没有其他月份日期的情况下迭代月份

我试图将 11 月的所有日子都作为 11 月的日期:

import calendar

calen = calendar.Calendar()        
calen_iter = calen.itermonthdates(2017,11)

for c in calen_iter: 
    print (c)
Run Code Online (Sandbox Code Playgroud)

我得到以下输出:

2017-10-30
2017-10-31
2017-11-01
2017-11-02
2017-11-03
<snipped lots of correct output>
2017-11-28
2017-11-29
2017-11-30
2017-12-01
2017-12-02
2017-12-03
Run Code Online (Sandbox Code Playgroud)

我不想要这些日期——它们为什么会出现?

2017-10-30
2017-10-31
2017-12-01
2017-12-02
2017-12-03
Run Code Online (Sandbox Code Playgroud)

python date

1
推荐指数
1
解决办法
451
查看次数

标签 统计

date ×1

python ×1