python为什么不能运行_为什么我不能在python中重新运行一个函数?

我刚完成作业作家程序,现在我有一个非常烦人的问题

我是这样做的,当一个函数完成时询问它是否要重新运行主函数,当我这样做,然后运行一个不同的函数(抱歉,如果我吮吸措辞的东西)该函数什么也不做。有什么我可以做的吗?

这是我的代码

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()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值