Python 强制原始输入
我将如何实施以下内容:Python 强制原始输入,python,Python,我将如何实施以下内容: title_selection = raw_input("Please type in the number of your title and press Enter.\n%s" % (raw_input_string)) if not title: # repeat raw_input 必须将title\u selection定义为',这意味着空(也是假)。 not将使False变为True(否定)。这通常是通过中间带有中断的“半循环”构造完成的: whil
title_selection = raw_input("Please type in the number of your title and press Enter.\n%s" % (raw_input_string))
if not title:
# repeat raw_input
必须将title\u selection
定义为'
,这意味着空(也是假)。
not
将使False
变为True(否定)。这通常是通过中间带有中断的“半循环”构造完成的:
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."
此方法使您可以轻松打印消息,告诉用户程序的期望值
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."