Skip to content
Advertisement

Ignoring escape characters in python

I am trying to insert a title into a DB. Sometimes the title has quotes and it throws an error.

I can’t replace quotes with a ” because it thinks that I am escaping the quote.

This replaces the quotes with more quotes so it changes nothing.

If I try to escape the backslash it doesn’t escape anything.

Advertisement

Answer

The best way to do this is using triple quotes, that’s interprets text inside as a string:

you either can format It was you want:

output:

Works on MySQL

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement