You need a fourfold backslash:
newstr = re.sub(mystr1 + "\\\\", "", myfile)
Cause:
- Regular match with one backslash:
\\ - The string to describe this regular expression is:
"\\\\" .
Or you can use a raw string, so you only need a double backslash: r"\\"
Tim pietzcker
source share