IOError: [Errno 2] No such file or directory: '0.txt' <p>I am writing a program to read a set of text files from folder "set" to a list.My code for this is</p> <pre><code>def get_documents(): path1 = "D:/set/" texts = [] listing1 = os.listdir(path1) for file in listing1: with open(file,'r') as f: lines = f.read().splitlines() texts.append(lines) </code></pre> <p>But this gives me Error as</p> <pre><code>with open(file,'r') as f: IOError: [Errno 2] No such file or directory: '0.txt' </code></pre> <p>There are text files inside <code>D:/set/</code> namely <code>0.txt,1.txt,2.txt...</code> What is the reason for this Error?</p>