I am aware of backslashes in programming. However, I pass the command line argument to the Python program for parsing. Spaces do not matter, but through the command line, spaces do matter. Therefore, I am trying to concatenate all argv [] arguments, except the first element, into a string, so that I can parse it later. However, the token of one "\" never occurs in a for loop.
Command line argument (notice the space around '\):
((1 * 2) + (3 - (4 \ 5)))
Program:
import sys string = "" for token in sys.argv[1:len(sys.argv)]: print(token) if "\\" in r"%r" % token: print("Token with \\ found") string += token print(string) print("done")
source share