python - How to Search in file with sub-string contain backslash and \n -


how search in file sub-string containing backslash?

substring="test\\123\\n" filename="temp.txt" file = open(filename, "r") line in file:     if re.search(substring, line): 

temp.txt

sometexttest\123\ntest secoundline ... etc 

how search string contain backslash , \n "test\\123\\n".
tried adding 1 more backslash not working.

is looking for?

substring="test\\1234\\n" filename="temp.txt" file = open(filename, "r")  line in file:     if substring in line:         print line 

giving output:

sometexttest\1234\ntest 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -