【发布时间】:2021-12-11 04:07:49
【问题描述】:
process1.py
import sys
with open("Main.txt", "w+") as sys.stdout:
eval(c)
在此代码中,c 的值已经定义,并且还创建了文本文件,但是当我尝试使用此代码打印文本文件 Main.txt 时,它引发了此错误 ValueError: I/O operation on closed file.
import process1
f = open("Main.txt", "r")
for x in f:
print(x)
我应该怎么做才能让它工作?
【问题讨论】:
标签: python input output valueerror