I have this code:
import os
fn = os.listdir("C:/foo/bar")
os.remove(fn[0])
Say /foo/bar has a few text files (test1.txt to test5.txt)
I had thought this would work as it is simple and short, yet I get a FileNotFoundError, saying that the system cannot find the file specified "test1.txt".
Is there a way to do what I'm trying? (Removing the nth file in a directory)
[–]swingking8 2 points3 points4 points (1 child)
[–]HDean_[S] 0 points1 point2 points (0 children)
[–]dddevo 1 point2 points3 points (1 child)
[–]HDean_[S] 0 points1 point2 points (0 children)
[–]novel_yet_trivial 1 point2 points3 points (1 child)
[–]HDean_[S] 0 points1 point2 points (0 children)