는 최근에 나는 경우 else 문에 작은 문제가 생겼어요. 즉 나는 그가 해당 스크립트를 작성하거나하지 않은 파일을 읽을 수 원하는지 입력을 사용자에게 요청하는 함수를 만들려면, 그래서 입력되면 입력 내가 다시 질문을 되돌리려 잘못된 경우 올바른 기능을하지만 그 일을한다.출력에 따라 Python에서 함수를 반복하는 방법은 무엇입니까?
여기에 코드입니다 :
는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"
돌아가서 자신을 반복하는 것입니다 물품.
당신이 구글을 시도 했습니까? – kirelagin
http://stackoverflow.com/questions/10563920/go-back-to-start-or-repeat-raw-input-a-number-of-times http://stackoverflow.com/questions/1781445/how- -l-raw-input-repeat-until-i-wanna-quit http://stackoverflow.com/questions/12557376/python-repeat-program-while-true – kirelagin