Python Forum
How do I handle escape character in parameter arguments in Python?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do I handle escape character in parameter arguments in Python?
#1
Hi,
I have the issue that Python change the string value of my parameter arguments.

Here are my skript parameter:

"C:\Ordner 1\" "D:\test 2\"

import sys
if len(sys.argv) > 1:    
    print(sys.argv[1])
    print(sys.argv[2])
The result is:

C:\Users\Joss\AppData\Local\Programs\Python\Python37-32\python.exe E:/test.py "C:\Ordner 1\" D:\test" 2\"
C:\Ordner 1" D:\test
2"

As you can see the parameters are torn in the wrong place because the escape character was executed. Angry

What I would like to see should be:

C:\Ordner 1\
D:\test 2\

I think Python shouldn't change any input string and give me the raw-string !
Reply


Messages In This Thread
How do I handle escape character in parameter arguments in Python? - by JKR - Sep-08-2023, 10:44 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Problems passing arguments containing spaces to bash script and then on to python kaustin 6 477 Apr-03-2024, 08:26 PM
Last Post: deanhystad
  Python rule about the space character surrounding the equal sign ineuw 10 1,760 Sep-21-2023, 09:17 AM
Last Post: ineuw
  use of escape character in re.sub and find WJSwan 1 942 Feb-16-2023, 05:19 PM
Last Post: Larz60+
  [ERROR] ParamValidationError: Parameter validation failed: Invalid type for parameter gdbengo 3 11,254 Dec-26-2022, 08:48 AM
Last Post: ibreeden
Question log.exception() without arguments in old Python versions? cthart 5 1,225 Nov-19-2022, 07:09 PM
Last Post: Gribouillis
  python call stored procedure with two parameter mg24 4 1,596 Sep-27-2022, 05:02 AM
Last Post: deanhystad
  Escape indentation Frankduc 11 3,169 Jan-31-2022, 02:41 PM
Last Post: Frankduc
  add Escape charcters in string GrahamL 3 1,211 Jan-20-2022, 01:15 PM
Last Post: GrahamL
  [solved] unexpected character after line continuation character paul18fr 4 3,473 Jun-22-2021, 03:22 PM
Last Post: deanhystad
  python error: bad character range \|-t at position 12 faustineaiden 0 3,726 May-28-2021, 09:38 AM
Last Post: faustineaiden

Forum Jump:

User Panel Messages

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