为什么python3 close函数无法关闭文件?可以帮忙看一下吗?

txt=open("Automatic.txt").read()
ls=txt.split()
print(ls)
new=open("abc.txt","w+").write(",".join(ls))
a=open("abc.txt","r").read()
n=a.split(",")
print(n)
#就是这一步开始出问题了
txt.close()
new.close()
a.close()

最后一步无法关闭文件,报错说是AttributeError: 'str' object has no attribute 'close',卡在这好久了,调试半天一点办法都没有(笑哭)

大话西游666
浏览 291回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP