如何在Python中使用「 with open」打開多個文件?

我想一次更改幾個文件, 前提是我能夠寫入全部文件。 我想知道我是否能夠將多個打開調用與with語句結合with : html try: with open('a', 'w') as a and open('b', 'w') as b: do_something() except IOError as e: print 'Operation failed: %s' % e.strer
相關文章
相關標籤/搜索