Quantcast
Channel: How do I check whether a file exists without exceptions? - Stack Overflow
Browsing all 46 articles
Browse latest View live

Answer by PierreBdR for How do I check whether a file exists without exceptions?

You have the os.path.exists function:import os.pathos.path.exists(file_path)This returns True for both files and directories but you can instead useos.path.isfile(file_path)to test if it's a file...

View Article


Answer by benefactual for How do I check whether a file exists without...

import osos.path.exists(path) # Returns whether the path (directory or file) exists or notos.path.isfile(path) # Returns whether the file exists or not

View Article


Answer by Paul for How do I check whether a file exists without exceptions?

import os.pathif os.path.isfile(filepath): print("File exists")

View Article

How do I check whether a file exists without exceptions?

How do I check whether a file exists or not, without using the try statement?

View Article

Answer by Milad Koohi for How do I check whether a file exists without...

All the answers were related to different versions of PythonBut I generally write the code on the version that is minimal.from os.path import existsfrom sys import argvscript,form_file = argvfile =...

View Article


Answer by Ban_Midou for How do I check whether a file exists without exceptions?

This is how i found a list of files(in this images) in one folder and searched it in a folder (with subfolders)# This script concatenates javascript files into a unified js to reduce server...

View Article
Browsing all 46 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>