os.path.exists`という関数がありますね。
import os.path
os.path.exists(file_path)
これはファイルとディレクトリの両方に対して True
を返しますが、代わりに
os.path.isfile(file_path)
を使って、ファイルかどうかを確認することができます。シンボリックリンクを辿ります。
import os
os.path.exists(path) # Returns whether the path (directory or file) exists or not
os.path.isfile(path) # Returns whether the file exists or not