FileNotFound Error 2 : No such file or directory | PYTHON

Published: 22 April 2020
on channel: Ex Gnyaana
18,941
94

In this tutorial video we will learn how to find out whether a file (or directory) exists using Python built-ins and functions from the standard library.
#python

Syntax:
import os
fn='C:\TEMP\Count\sales.csv'

if os.path.exists(fn)==True:
#do whatever you want
print('File exists. Hurray!!!!')
else:
print("File does not exists. Please check the extension. etc bla bla")

Other Options:
os.path.isfile()
open() and try...except


Watch video FileNotFound Error 2 : No such file or directory | PYTHON online without registration, duration hours minute second in high quality. This video was added by user Ex Gnyaana 22 April 2020, don't forget to share it with your friends and acquaintances, it has been viewed on our site 18,941 once and liked it 94 people.