最近我对 if else 语句有一个小问题。也就是说,我想创建一个函数,询问用户是否要读取脚本创建的文件,所以如果输入正确,函数会执行它的操作,但是当输入不正确时,我希望它再次恢复问题。
这是代码:
def read_the_file(output):
print """
Do you want me to read your newly created file?
Type [Y]es or [N]o
"""
question = raw_input("> ")
reading = output.read()
if question == 'yes'or question == 'Y' or question == 'y':
print "BEGINNING OF FILE\n\n" + reading + "\n END OF FILE"
elif question == 'no' or question == 'N' or question == 'n':
sys.exit[1]
else :
print "wrong input"
read_the_file(output_file)
所以我想要这个函数做的是写
else:
print "wrong input"
就是回去重演。