I\'m trying to find a way to print a string in raw form from a variable. For instance, if I add an environment variable to Windows for a path, which might look like \'
\'
try this. Based on what type of output you want. sometime you may not need single quote around printed string.
test = "qweqwe\n1212as\t121\\2asas" print(repr(test)) # output: 'qweqwe\n1212as\t121\\2asas' print( repr(test).strip("'")) # output: qweqwe\n1212as\t121\\2asas