How to check if an error occurred while reading/writing a file within “with” statement?

后端 未结 0 431
失恋的感觉
失恋的感觉 2021-01-22 07:13

In Python tutorials it is usually highly recommended to wrap file reading/writing operations into With statement:

with open(“testfile.txt”) as file:
    data = fi         


        
相关标签:
回答
  • 消灭零回复
提交回复
热议问题