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 (全て見る)
- python : pyscript - 2022年5月16日
- python : logging モジュールの使い方 - 2022年5月16日
- 機械名:号機:顧客番号 - 2022年2月17日