Python Forum
Coding error. Can't open directory
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Coding error. Can't open directory
#6
/home/pi/Downloads/words.txt is Linux/Mac path
C:\Users\hp\Desktop\words.txt is Windows

1. Using raw string to handle back-slash correctly
with open(r"C:\Users\hp\Desktop\words.txt", "rt") as f:
or

escaping the back-slash
with open("C:\\Users\\hp\\Desktop\\words.txt", "rt") as f:
or
using forward slash
with open("C:/Users/hp/Desktop/words.txt", "rt") as f:

And this was already covered in your first thread on the forum

https://python-forum.io/thread-39705.html
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
Coding error. Can't open directory - by EddieG - Jul-12-2023, 01:34 PM
RE: Coding error. Can't open directory - by EddieG - Jul-12-2023, 01:52 PM
RE: Coding error. Can't open directory - by EddieG - Jul-13-2023, 08:39 AM
RE: Coding error. Can't open directory - by buran - Jul-13-2023, 08:47 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Coding error. xflyerwdavis 2 569 Oct-07-2023, 07:08 PM
Last Post: deanhystad
  Coding Error EddieG 2 578 Jul-09-2023, 02:59 AM
Last Post: EddieG
  Using pyinstaller with .ui GUI files - No such file or directory error diver999 3 3,664 Jun-27-2023, 01:17 PM
Last Post: diver999
  Error when using Watchdog and Qt to keep open a Queue before and after sending first pyhill00 0 1,641 Oct-28-2021, 09:10 AM
Last Post: pyhill00
  Error about missing directory Led_Zeppelin 3 2,815 Aug-31-2021, 01:37 PM
Last Post: snippsat
  Error on open of file created with tempfile.TemporaryDirectory() Brian177 4 6,435 Apr-05-2021, 07:12 PM
Last Post: Brian177
  List of error codes to find (and count) in all files in a directory tester_V 8 3,821 Dec-11-2020, 07:07 PM
Last Post: tester_V
  python coding error isntitzee 1 2,245 Oct-17-2020, 06:30 AM
Last Post: buran
  Coding error- Not sure where I have put error markers against the code that is wrong Username9 1 1,779 Sep-28-2020, 07:57 AM
Last Post: buran
  coding error iro a menu Rollo 2 2,149 Sep-27-2020, 04:17 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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