How can I open multiple files using “with open” in Python?

后端 未结 7 809
天涯浪人
天涯浪人 2020-11-22 08:15

I want to change a couple of files at one time, iff I can write to all of them. I\'m wondering if I somehow can combine the multiple open calls with the

相关标签:
7条回答
  • 2020-11-22 09:13

    With python 2.6 It will not work, we have to use below way to open multiple files:

    with open('a', 'w') as a:
        with open('b', 'w') as b:
    
    0 讨论(0)
提交回复
热议问题