when I use open() in python it says FileNotFound, only when I try to open files with spacing in naming, (for e.g. example text.txt)
I tried using with open('Users/vandit/Desktop/example\ text.txt', 'rb') as f:
when I use open() in python it says FileNotFound, only when I try to open files with spacing in naming, (for e.g. example text.txt)
I tried using with open('Users/vandit/Desktop/example\ text.txt', 'rb') as f:
The '\' is only used in the shell to escape the following space. In python, you can just include the whole thing in quotes:
with open('Users/vandit/Desktop/example text.txt', 'w') as f:
Also (if you are on windows) if you still get an error, try prepending the string with the drive in which your Windows is installed, which is mostly C:\. So it will become: with open('C:/Users/vandit/Desktop/example text.txt', 'w') as f: