I was just experimenting with the pathlib
library in Python 3.6
. I wanted to check if such a file with the given file name exists in the path that I have given. Here is my code:
from pathlib import Path
f = Path('/Libraries/Documents/sample.txt')
print("File {} Exists".format(f)) if f.exists() else print("False")
And the output that I got was:
>>> False
while such a file truly existed in that path.
What could be the possible error in the above code?