I was trying to learn the Image library and wanted to setup a function which checks if the path is valid because why not, and I found that I can’t open files if the folders have a space in the name, for example, "E:New foldermovie.png"
. I wonder if I was doing something wrong or is it just impossible to open a file with spaces in the name.
This is the code I used
def file_path_check(): path = input("Enter file path: ") os.startfile((path))
and the error I receive when I use the above file path
Enter file path: "E:New foldermovie.png" Traceback (most recent call last): File "E:vscode_projectspython_projectsfile.py", line 4, in <module> os.startfile((path)) ~~~~~~~~~~~~^^^^^^^^ FileNotFoundError: [WinError 2] The system cannot find the file specified: '"E:\New folder\movie.png"'
submitted by /u/Plastic_Ad_7733
[link] [comments]
r/learnpython I was trying to learn the Image library and wanted to setup a function which checks if the path is valid because why not, and I found that I can’t open files if the folders have a space in the name, for example, “E:New foldermovie.png”. I wonder if I was doing something wrong or is it just impossible to open a file with spaces in the name. This is the code I used def file_path_check(): path = input(“Enter file path: “) os.startfile((path)) and the error I receive when I use the above file path Enter file path: “E:New foldermovie.png” Traceback (most recent call last): File “E:vscode_projectspython_projectsfile.py”, line 4, in <module> os.startfile((path)) ~~~~~~~~~~~~^^^^^^^^ FileNotFoundError: [WinError 2] The system cannot find the file specified: ‘”E:\New folder\movie.png”‘ submitted by /u/Plastic_Ad_7733 [link] [comments]
I was trying to learn the Image library and wanted to setup a function which checks if the path is valid because why not, and I found that I can’t open files if the folders have a space in the name, for example, "E:New foldermovie.png"
. I wonder if I was doing something wrong or is it just impossible to open a file with spaces in the name.
This is the code I used
def file_path_check(): path = input("Enter file path: ") os.startfile((path))
and the error I receive when I use the above file path
Enter file path: "E:New foldermovie.png" Traceback (most recent call last): File "E:vscode_projectspython_projectsfile.py", line 4, in <module> os.startfile((path)) ~~~~~~~~~~~~^^^^^^^^ FileNotFoundError: [WinError 2] The system cannot find the file specified: '"E:\New folder\movie.png"'
submitted by /u/Plastic_Ad_7733
[link] [comments]