【发布时间】:2019-11-24 00:43:15
【问题描述】:
这是我的一段代码,由于某种原因,即使我输入正确的上午或下午,它也会继续
while True:
user_in = input('Please enter the time in the following 12Hour format HH:MM AM|PM : ')
time_in = user_in.split()
time_input = time_in[0].split(':')
latin_input = time_in[1]
if (latin_input != 'AM' and latin_input != 'PM'):
continue
else:
break
【问题讨论】:
-
hmmm 对我来说似乎工作正常。您能提供您使用的输入吗?
-
试试
'AM' not in latin_input and 'PM' not in latin_input。
标签: python python-3.x loops user-input