如果这个代码中b=3,m=1的话不是应该输出60吗,为什么会输出62呢?
for yue in range(1,b):
if yue==1 or 3 or 5 or 7 or 8 or 10 or 12:
yuezongshu=yuezongshu+31
elif yue==4 or 6 or 9 or 11:
yuezongshu=yuezongshu+30
else:
if m==1:
yuezongshu=yuezongshu+29
else:
yuezongshu=yuezongshu+28
print(yuezongshu)
if yue in [1, 3, 5, 7, 8 , 10 , 12]:
或者
if yue==1 or yue==3 or yue==5 or yue==7 or yue==8 or yue==10 or yue==12:
确实是60啊
#!/usr/bin/env python
#-*- coding:utf-8 -*-
b=3
m=1
yuezongshu = 0
for yue in range(1,b):
if yue in [1,3,5,7,8,10,12]:
yuezongshu = yuezongshu+31
elif yue in [4,6,9,11]:
yuezongshu = yuezongshu+30
else:
if m == 1:
yuezongshu = yuezongshu+29
else:
yuezongshu=yuezongshu+28
print(yuezongshu)