python 报错:ValueError: I/O operation on closed file

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/qq262593421/article/details/102712746

This is wrong python file read and write frequently encounter

Given reasons: with open (filename) as f : f variable is valid only in the block , will automatically turn off after use I / O stream

The solution: a redefinition of open (fillename) with as variable or re-use statement

Guess you like

Origin blog.csdn.net/qq262593421/article/details/102712746