93
77

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

pythonでファイルの存在を確認する

Posted at
import os
path = "./sample"

os.path.exists(path)

これでsampleと言う名前のファイル、またはディレクトリの存在を確認できる。

ちなみに、ディレクトリを含まず、ファイルだけを確認したい場合は、

os.path.isfile(path)

ファイルを含まず、ディレクトリだけを確認したい場合は

os.path.isdir(path)

でできる

93
77
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
93
77

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?