You need a quadruple backslash:
newstr = re.sub(mystr1 + "\\\\", "", myfile)
Reason:
- Regex to match a single backslash:
\\
- String to describe this regex:
"\\\\"
.
Or you can use a raw string, so you only need a double backslash: r"\\"
More Related Contents:
- Results from my program [closed]
- How do I properly start creating a programming language in python? [closed]
- Adding Python to PATH on Windows
- Reading a huge .csv file
- How to print a string at a fixed width?
- How to use pip with Python 3.x alongside Python 2.x
- How do you create nested dict in Python?
- Python – ‘ascii’ codec can’t decode byte
- Remove text between () and []
- Securely storing environment variables in GAE with app.yaml
- Selenium Webdriver in Python – files download directory change in Chrome preferences
- How to pip or easy_install tkinter on Windows
- pip install gives error: Unable to find vcvarsall.bat
- Python dynamic function creation with custom names
- gcc-4.2 failed with exit status 1
- What does an ‘r’ represent before a string in python? [duplicate]
- Sort a list to form the largest possible number
- Get unicode code point of a character using Python
- How to split dictionary into multiple dictionaries fast
- Distributed lock manager for Python
- Spell Checker for Python
- How can I use io.StringIO() with the csv module?
- Avoid Twitter API limitation with Tweepy
- Why do I get “‘str’ object has no attribute ‘read'” when trying to use `json.load` on a string? [duplicate]
- Jupyter | The kernel appears to have died. It will restart automatically |
- ImportError: DLL load failed when importing Numpy installed in conda virtual environment
- Catching exception in context manager __enter__()
- confused about random_state in decision tree of scikit learn
- Is possible to mapping view with class using mapper in SqlAlchemy?
- How to handle IncompleteRead: in python