Python Forum
opening a file from a windows desktop folder- error opening file - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: opening a file from a windows desktop folder- error opening file (/thread-14553.html)



opening a file from a windows desktop folder- error opening file - Charan007 - Dec-06-2018

Hi Team,

I am trying to open a file that is available in the desktop folder with the below command but getting an error
that file is not present.

I don't have access to place the input file in the python folder to open the file.

code:
a=r'C:\Users\Charan\Desktop\Python\sample.txt'
b=open(a,'r')
error:
Error:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\Charan\\Desktop\\Python\\sample.txt'



RE: opening a file from a windows desktop folder- error opening file - buran - Dec-06-2018

it looks OK and should work given the file exists. Sorry, but can you confirm one more time that file with that name exists at the this location?
(Dec-06-2018, 01:03 AM)Charan007 Wrote: a file that is available in the desktop folder
i.e. is the file on the Desktop or in a Python folder on the Desktop?