while True:
title_selection = raw_input("Please type in the number of your title and press Enter.\n%s" % (raw_input_string))
if title_selection:
break
print "Sorry, you have to enter something."
title_selection = ''
while not title_selection:
title_selection = raw_input("Please type in the number of your title and press Enter.\n%s" % (raw_input_string))
这通常是用一个中间带有
break
的“循环半”结构完成的:此方法使您可以轻松地打印一条消息,告诉用户程序期望的内容。在
必须在hand之前将}为真(否定)。在
title_selection
定义为''
,这意味着空(也是False)。not
将使{相关问题 更多 >
编程相关推荐