Python Forum
Phyton Opening files on windows C: pc
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Phyton Opening files on windows C: pc
#1
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.
Reply


Messages In This Thread
Phyton Opening files on windows C: pc - by EddieG - Mar-29-2023, 11:43 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Rename files in a folder named using windows explorer hitoxman 3 791 Aug-02-2023, 04:08 PM
Last Post: deanhystad
Exclamation Phyton Metin2 Game Left Click not working. Help anonym35 0 1,564 Feb-02-2022, 07:01 PM
Last Post: anonym35
  Copying files from a remote Windows station tester_V 11 6,999 Jul-17-2021, 02:19 AM
Last Post: tester_V
  opening files and output of parsing leodavinci1990 4 2,602 Oct-12-2020, 06:52 AM
Last Post: bowlofred
  Opening and closing Mac applications and files Nickd12 5 5,802 Sep-05-2020, 04:39 AM
Last Post: perfringo
  PYHTON not opening files profficial 11 13,735 Feb-15-2020, 09:06 AM
Last Post: bharathendra
  Phyton code to load a comma separated csv file in to a dict and then in to a dB mrsenorchuck 2 2,690 Nov-29-2019, 10:59 AM
Last Post: mrsenorchuck
  Code works in IDLE, appears to work in CMD, but won't produce files in CMD/Windows ChrisPy33 3 3,273 Jun-12-2019, 05:56 AM
Last Post: ChrisPy33
  opening a file from a windows desktop folder- error opening file Charan007 1 3,014 Dec-06-2018, 11:50 AM
Last Post: buran
  Python files made on linux don't work on windows sylas 2 3,298 Oct-10-2018, 05:34 AM
Last Post: sylas

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020