2021-03-02 13:23

# 求求了，一个小bug硬是找不出来

``````text1,text2,text3,text4=input(),input(),input(),input()
alp=['A','B','C','D','E','F','G']
alp3=['A','B','C','D','E','F','G','H','I','J','K','L','M','N']
day=['MON','TUE','WED','THU','FRI','SAT','SUN']
time=['10','11','12','13','14','15','16','17','18','19','20','21','22','23']
num=['0','1','2','3','4','5','6','7','8','9']
numa,numb,numc=0,0,0
DAY='0'
for p in range(len(text1)):
if text1[p]==text2[p]:
if DAY=='0' and numb==0:
if text1[p] in alp:
DAY=day[alp.index(text1[p])]
numb=1
else:
if numc==0:
if text1[p] in alp3:
HH=time[alp3.index(text1[p])]
numc=1
elif text1[p] in num:
HH='0'+str(text1[p])
numc=1
for p in range(len(text3)):
if numa==0:
if text3[p]==text4[p]:
if text3[p].isalpha():
if p<10:
MM='0'+str(p)
numa=1
else:
MM=str(p)
numa=1
print(DAY+' '+HH+':'+MM)
``````

• 点赞
• 写回答
• 关注问题
• 收藏
• 复制链接分享
• 邀请回答

#### 1条回答

• qq_34124780 1月前

你有没有考虑到如果text1和text2的长度关系？如果len(text1)>len(text2)，你的第10行text2[p]数组越界不就是非零返回吗。同样道理，text3和text4也会有这个问题的。

点赞 1 评论 复制链接分享