Oct-28-2022, 04:19 AM
(This post was last modified: Oct-28-2022, 02:05 PM by deanhystad.)
If it is coming from the command line than it is already a str object and not a str literal. raw does not apply.
I did a little experiment. I wrote a program to spit out the command line argument
If backslashes are giving you headaches, use forward slashes. Windows accepts forward slash as a path seperator.
I did a little experiment. I wrote a program to spit out the command line argument
import sys print(f"{sys.argv[1]}, {repr(sys.argv[1])}, {len(sys.argv[1])}"I ran the program as "python text.py "\\\n". This was the output.
Output:\\\n, '\\\\\\n', 4
The repr version of the command line argument looks odd, but the length shows this is an artifact of repr trying to show you that the string really contains "\\" and "\n" and not escape<\> and escape<n>.If backslashes are giving you headaches, use forward slashes. Windows accepts forward slash as a path seperator.