python - Convert escape characters in strings (like "\\n" - two characters) into ASCII character (newline) -
my program got string command line arguments, contains many escapes characters.
./myprog.py "\x41\x42\n"
when print "sys.argv[1]". got on screen:
\x41\x42\n
is there simple way program print instead:
ab[newline]
try passing argument in following way:
./myprog.py $'\x41\x42\n'
the $'...'
notation allowed used \x00
-like escape sequences constructing arbitrary byte sequences hexadecimal notation.
another way fix @barak suggested here -- converting hex
characters. depends on find easy you.
Comments
Post a Comment