You have to escape the “\”:
str.replace("'","\\'")
“\” is an escape sequence indicator, which, to be used as a normal char, has to be escaped (by) itself.
Related Posts:
- Renaming column names in Pandas
- TypeError: ‘float’ object is not subscriptable
- TypeError: ‘float’ object is not subscriptable
- Finding and replacing elements in a list
- Replace values in list using Python
- Best way to replace multiple characters in a string?
- Best way to replace multiple characters in a string?
- Replace and overwrite instead of appending
- Using replace() method in python by index
- How to replace multiple substrings of a string?
- Remove specific characters from a string in Python
- pandas replace multiple values one column
- Difference between del, remove, and pop on lists
- How to use the pass statement
- How do you round UP a number?
- How do I update\upgrade pip itself from inside my virtual environment?
- ImportError: DLL load failed: The specified module could not be found
- Replacements for switch statement in Python?
- Correct way to write line to file?
- How to read a file line-by-line into a list?
- How do I sort a dictionary by value?
- What does hash do in python?
- How to copy a dictionary and only edit the copy
- Creating a static class with no instances
- How to avoid “RuntimeError: dictionary changed size during iteration” error?
- if/else in a list comprehension
- Could not find a version that satisfies the requirement tensorflow
- Creating an empty Pandas DataFrame, then filling it?
- Finding the average of a list
- How to solve dictionary changed size during iteration error?
- iloc giving ‘IndexError: single positional indexer is out-of-bounds’
- What does “\r” do in the following script?
- Anaconda vs. miniconda
- No module named serial
- ImportError: No module named psycopg2
- DataFrame constructor not properly called
- How does functools partial do what it does?
- What is the problem with shadowing names defined in outer scopes?
- TypeError: write() argument must be str, not bytes (Python 3 vs Python 2 )
- How to clear the interpreter console?
- How to make a class JSON serializable
- What does the ‘b’ character do in front of a string literal?
- Python string.replace regular expression
- How can I upgrade NumPy?
- How to get element-wise matrix multiplication (Hadamard product) in numpy?
- Matplotlib automatic legend outside plot
- Why am I getting this syntax error: keyword can’t be an expression
- Django: ImproperlyConfigured: The SECRET_KEY setting must not be empty
- What is dtype(‘O’), in pandas?
- ctypes – Beginner
- Keras, how do I predict after I trained a model?
- How do I find out my PYTHONPATH using Python?
- ValueError: could not broadcast input array from shape (224,224,3) into shape (224,224)
- Overflow Error in Python’s numpy.exp function
- Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock
- ModuleNotFoundError: No module named ‘MySQLdb’
- How to change dataframe column names in pyspark?
- Normalize data in pandas
- Can’t broadcast input array from shape (3,1) into shape (3,)
- How to create an array of bits in Python?
- Setting Django up to use MySQL
- In Python, when to use a Dictionary, List or Set?
- How can I check for NaN values?
- Python – how to use the constant e^
- Check if two unordered lists are equal
- How to read a file without newlines?
- Encrypt & Decrypt using PyCrypto AES 256
- Is there a list of Pytz Timezones?
- Flask example with POST
- How do I change the figure size with subplots?
- Clear terminal in Python [duplicate]
- can’t open tensorboard 0.0.0.0:6006 or localhost:6006
- ImportError: No module named six
- Easy pretty printing of floats?
- Algorithm for solving Sudoku
- How to read pickle file?
- How does str(list) work?
- Automatic indentation for Python in Notepad++
- pandas groupby sort within groups
- Python Socket Receive Large Amount of Data
- What is a “slug” in Django?
- How to find out whether a file is at its `eof`?
- TypeError: Image data can not convert to float
- coercing to Unicode: need string or buffer, NoneType found when rendering in django admin
- Convert from ASCII string encoded in Hex to plain ASCII?
- Simple way to create matrix of random numbers
- pandas: multiple conditions while indexing data frame – unexpected behavior
- ‘instancemethod’ object has no attribute ‘__getitem__’ with class variables
- Python/Scikit-Learn – Can’t handle mix of multiclass and continuous
- How can I tail a log file in Python?
- How to write unicode strings into a file?
- python-How to set global variables in Flask?
- How do I install pip on macOS or OS X?
- NameError: name ‘get_ipython’ is not defined
- Equivalent to matlab’s imagesc in matplotlib? [duplicate]
- bash: syntax error near unexpected token `(‘ – Python
- Find all files in a directory with extension .txt in Python
- “public” or “private” attribute in Python ? What is the best way?
- How to search for a string in text files?
- TypeError: ‘zip’ object is not subscriptable