Quantcast
Viewing latest article 29
Browse Latest Browse All 47

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

This is the simplest way to check if a file exists. Just because the file existed when you checked doesn't guarantee that it will be there when you need to open it.

import osfname = "foo.txt"if os.path.isfile(fname):    print("file does exist at this time")else:    print("no such file exists at this time")

Viewing latest article 29
Browse Latest Browse All 47

Trending Articles



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