def main():
infileName = input("Insert To do list file: ")
outfileName = input("Insert the new to do list: ")
infile = open(infileName, "r")
todolist = infile.readlines()
outfile = open(outfileName, "w")
for i in range(len(todolist)):
print(todolist[i], file = outfile)
infile.close()
outfile.close()
print("New list prints to",outfileName)
main()
我總是收到一條錯誤消息,說print(todolist[i], file = outfile) ValueError: I/O operation on closed file.
請幫助。試圖創建一個從infile到outfile的數字的列表
所有我想要做的是從被列爲
do hw
throw away trash
shower dog
和我要的是
1. do hw
2. throw away trash
3. shower dog