![jupyterでFileの操作](https://take-web.com/auto/wp-content/uploads/2021/01/jupyter_file.png)
![](http://take-web.com/auto/wp-content/themes/cocoon-master/images/man.png)
今回は、JupyterでPythonのFile操作を色々試してみたいと思います。
JWWの座標ファイルで使いたいと思っています。
openでファイルを開く
with open("G:\\App\\JWW\\ZTEMP.TXT") as f:
print(f)
<_io.TextIOWrapper name='G:\\App\\JWW\\ZTEMP.TXT' mode='r' encoding='cp932'>
withを使うと、最後にFile閉じなくていいです。
ファイルを変数に読み込む .read()
with open("G:\\App\\JWW\\ZTEMP.TXT") as f:
s=f.read()
print(s)
ci 0 0 50 ci 0 0 25 ci 0 0 10 ci 0 0 200 ci 0 0 100
これで、ファイルの内容すべて変数に入りました。
コメント