PythonのファイルIO
次のコードは、読み取り、書き込み、オープンを含むPythonの基本的なファイル操作を、示しています。
# Filename : test.py # author by : www.w3big.com # 写文件 with open("test.txt", "wt") as out_file: out_file.write("该文本会写入到文件中\n看到我了吧!") # Read a file with open("test.txt", "rt") as in_file: text = in_file.read() print(text)
上記のコードの出力結果を実行します。
该文本会写入到文件中 看到我了吧!