Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
2 つの異なる方法で 1 つのファイルだけを書き込もうとしています。
別の保存方法を作成せずにそれを行うことができる方法はありますか?
このような?
def method1(f): f.write("something") def method2(f): f.write("something else") with open("myfile", "w") as f: method1(f) method2(f)