Python Forum
Question: Paths and writing to a file
Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Question: Paths and writing to a file
#7
(Dec-20-2016, 03:15 PM)snippsat Wrote: And remember never a single backslash this way \.
You are lucky here because not hitting any escape character.
Eg with an other file name it had gone wrong.
>>> s = 'C:\projects\Dec-20-16\test.txt'
>>> print(s)
C:\projects\Dec-20-16    est.txt
So always \\\ or / or r'path'

Yes, I have missed that. os.path module can handle paths pretty well.
https://docs.python.org/3/library/os.path.html
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Messages In This Thread
Question: Paths and writing to a file - by mwmaw - Dec-20-2016, 08:12 AM
RE: Question: Paths and writing to a file - by wavic - Dec-20-2016, 03:44 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Absolute paths in subprocess - file not found kittyticker 4 401 Jan-28-2024, 10:37 PM
Last Post: kittyticker
  Navigating file directories and paths inside Jupyter Notebook Mark17 5 627 Oct-29-2023, 12:40 PM
Last Post: Mark17
  Writing string to file results in one character per line RB76SFJPsJJDu3bMnwYM 4 1,306 Sep-27-2022, 01:38 PM
Last Post: buran
  Writing to json file ebolisa 1 970 Jul-17-2022, 04:51 PM
Last Post: deanhystad
  pdf2image, poppler and paths jehoshua 18 13,949 Jun-14-2022, 06:38 AM
Last Post: jehoshua
  Windows paths issue otalado 3 1,417 May-29-2022, 09:11 AM
Last Post: snippsat
  Writing to External File DaveG 9 2,409 Mar-30-2022, 06:25 AM
Last Post: bowlofred
  automatically get absolute paths oclmedyb 1 2,062 Mar-11-2021, 04:31 PM
Last Post: deanhystad
  Writing to file ends incorrectly project_science 4 2,641 Jan-06-2021, 06:39 PM
Last Post: bowlofred
  Writing unit test results into a text file ateestructural 3 4,654 Nov-15-2020, 05:41 PM
Last Post: ateestructural

Forum Jump:

User Panel Messages

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