嘿伙计们还在这里:)
我得到 ValueError: I/O operation on closed file 错误。
db = open(r"C:\Users\PC\Desktop\db.txt", "a+")
print("""-Type 1 for add film
-Type 2 for see your films
""")
while True:
enter = input("Please Enter: ")
if enter == "1":
film=input("Enter film: ")
db.write(film + "\n")
db.close()
elif enter == "2":
print("Your's films: ")
db.seek(0)
print(db.read())
db.close()
elif giris == "":
print("Please type something!")
else:
print("Error!")
当我输入 1 时,我添加了电影并再次输入 2 以查看我的电影。我得到 ValueError: I/O operation on closed file error :(