Mar-29-2023, 11:43 AM
Hello,
A newbie here. I am into my lesson opening files on Python. The lesson is to copy a poem on the text editor (note++) . I saved the poem on my desktop for easy locating when required.
Actual Windows path
(C:\User\hp\desktop\Poem.txt)
However following the open() function example to pass the file into a variable as object.
poem=open("/home/pi/Document/Poen.txt")
results in a error no file found.
using the textbook example to open the file as
poem=open("C:/User/hp/desktop/Poem.txt")
When the code was written in the shell, pressing enter returns a file not error:
Python Version 3.11.2
What is the correct way to tell Python where to find the file in this situation. A spoon fed code (written full code) using the windows C: path answer is most welcome.
Thank you for your response in advance.
A newbie here. I am into my lesson opening files on Python. The lesson is to copy a poem on the text editor (note++) . I saved the poem on my desktop for easy locating when required.
Actual Windows path
(C:\User\hp\desktop\Poem.txt)
However following the open() function example to pass the file into a variable as object.
poem=open("/home/pi/Document/Poen.txt")
results in a error no file found.
using the textbook example to open the file as
poem=open("C:/User/hp/desktop/Poem.txt")
When the code was written in the shell, pressing enter returns a file not error:
Python Version 3.11.2
What is the correct way to tell Python where to find the file in this situation. A spoon fed code (written full code) using the windows C: path answer is most welcome.
Thank you for your response in advance.