Python Forum
string to file parameter oddity
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
string to file parameter oddity
#2
That has nothing to do with files. Backslash (ie: \) is an escape character. If you want to actually use one in a string, you need to escape it: \\. The only reason it's working for you, is because you marked the string as raw (that's what the "r" in front of your path means). You could also use a single forward slash... python will do The Right Thing depending on what os you're on, so "c:/temp/test.txt" == "c:\\temp\\test.txt" == r"c:\temp\test.txt" == "c:/temp\\test.txt" == r"c:/temp\test.txt".
...but don't mix between the two in a single string. Other people will hate you for purposefully making things hard to read, lol.
Reply


Messages In This Thread
string to file parameter oddity - by meems - Nov-16-2016, 07:17 PM
RE: string to file parameter oddity - by nilamo - Nov-16-2016, 08:39 PM
RE: string to file parameter oddity - by meems - Nov-17-2016, 09:20 AM
RE: string to file parameter oddity - by heiner55 - Nov-17-2016, 12:11 PM
RE: string to file parameter oddity - by meems - Nov-17-2016, 12:31 PM
RE: string to file parameter oddity - by heiner55 - Nov-17-2016, 03:26 PM
RE: string to file parameter oddity - by nilamo - Nov-17-2016, 03:57 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Need to replace a string with a file (HTML file) tester_V 1 904 Aug-30-2023, 03:42 AM
Last Post: Larz60+
  [ERROR] ParamValidationError: Parameter validation failed: Invalid type for parameter gdbengo 3 11,822 Dec-26-2022, 08:48 AM
Last Post: ibreeden
  [SOLVED] Input parameter: Single file or glob? Winfried 0 1,641 Sep-10-2021, 11:54 AM
Last Post: Winfried
  How to fill parameter with data from multiple columns CSV file greenpine 1 1,741 Dec-21-2020, 06:50 PM
Last Post: Larz60+
  I need my compiled Python Mac app to accept a file as a parameter Oethen 2 2,520 May-10-2020, 05:57 PM
Last Post: Oethen
  Python Parameter inside Json file treated as String dhiliptcs 0 1,922 Dec-10-2019, 07:28 PM
Last Post: dhiliptcs
  TreeTagger : parameter file invalid : english.par Raph0909 0 2,870 Apr-12-2019, 12:12 PM
Last Post: Raph0909
  Help with python code to search string in one file & replace with line in other file mforthman 26 12,348 Dec-19-2017, 07:11 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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