0
방금 숙제 작가 프로그램을 마쳤으며 이제는 정말 귀찮은 문제가 생겼습니다.왜 파이썬에서 함수를 다시 실행할 수 없습니까?
기능을 마치면 주 기능을 다시 실행할지 묻는 메시지가 나타납니다. 미안 내가 말씨 것들을 빨아) 함수는 전혀 아무것도하지 않습니다. 내가 할 수 있는게 있습니까?
여기에 내가 지금 python3이 없기 때문에 내가 python2.7에서 코드를 실행 내 코드
agenda=open("agenda.txt","a") #open the notepad file
def choice(): #pick the period
choice=input("type write, read, or clear\n")
if choice=="read":
read()
elif choice=="write":
write()
elif choice=="clear":
clear()
else:
print("Invalid Choice")
def write(): #write the homework
per=input("What period is it")
hw=input("What is the homework")
if per=="1":
agenda.write("Period 1:")
agenda.write(hw)
agenda.write("\n")
elif per=="2":
agenda.write("Period 2:")
agenda.write(hw)
agenda.write("\n")
elif per=="3":
agenda.write("Period 3:")
agenda.write(hw)
agenda.write("\n")
elif per=="4":
agenda.write("Period 4:")
agenda.write(hw)
agenda.write("\n")
elif per=="5":
agenda.write("Period 5:")
agenda.write(hw)
agenda.write("\n")
elif per=="6":
agenda.write("Period 6:")
agenda.write(hw)
agenda.write("\n")
elif per=="7":
agenda.write("Period 7:")
agenda.write(hw)
agenda.write("\n")
elif per=="8":
agenda.write("Period 8:")
agenda.write(hw)
agenda.write("\n")
else:
print("Non existant period")
again=input("Would you like to read the homework, clear, or read again? (yes or no)")
if again=="yes":
choice()
elif again=="no":
print("\n")
def clear():#clear the whole thing
ajenda = open('agenda.txt', 'r+')
ajenda.truncate()
again=input("Would you like to read the homework, clear, or read again? (yes or no)")
if again=="yes":
choice()
elif again=="no":
print("\n")
def read():#read the homework
read=open("agenda.txt","r")
readf=read.read()
print(readf)
read.close
again=input("Would you like to read the homework, clear, or read again? (yes or no)")
if again=="yes":
choice()
elif again=="no":
print("\n")
choice()
agenda.close()
예상 결과와 함께 프로그램을 출력하면 도움이 될 수 있습니다. –
input() 대신 raw_input()을 사용하려고한다고 생각합니다. –
@VaughnCato : raw_input은 python 3에서 사라졌습니다. –