1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
import os # test.txtファイルは存在するかを調べる print(os.path.exists("test.txt")) # それはファイルなのかを確認する print(os.path.isfile("test.txt")) # それはディレクトリなのかを確認する print(os.path.isdir("test.txt")) # ファイルを作成する with open("test.txt", "w") as f: pass # リネームする os.rename("test.txt", "renamed.txt") # シムリンクもできる。 # symlink.txtの内容を変更するとtest2.txtも同じく変更される。 # ショートカットのようなもの # ただし gpedit > シンボリックリンクの作成 サインアウトが必要 # 参考URL https://kokufu.blogspot.com/2018/03/symbolic-link-privilege-not-held.html # windows10homeではできないかもしれない # os.symlink("renamed.txt", "symlink.txt") # ディレクトリを作成して、削除 os.mkdir("test_dir") os.rmdir("test_dir") |
The following two tabs change content below.
Keita N
最新記事 by Keita N (全て見る)
- DDPG by gymnasium 15日目 - 2023年6月2日
- DDPG by gymnasium 14日目 - 2023年6月1日
- DDPG by gymnasium 13日目 - 2023年5月28日