Insp
Insp

Reputation: 11

What is the escape character for % in python's string method

I am trying to pass a string which has a '%' in it (its actually a sql query string). How do I pass the % (do I have to use a specific escape character?

eg: compute_answertime("%how do I%")

Upvotes: 1

Views: 194

Answers (3)

Muhammad Alkarouri
Muhammad Alkarouri

Reputation: 24652

You can use:

%%; DROP TABLE Students; --

Sorry, couldn't resist.

Upvotes: 1

use %%..........

Upvotes: 1

Johannes Charra
Johannes Charra

Reputation: 29913

Use another % to escape it

>>> compute_answertime("%%how do I%%")

Upvotes: 4

Related Questions