Ranga Sarin
Ranga Sarin

Reputation: 169

Python encode string to html

How would one take a string and encode special characters to html?

for example, if I have "test@test" how would I encode it so it becomes "test%40test"

Is there an easy way of doing this instead of using replace to manually list every one I want to replace?

Upvotes: 1

Views: 3551

Answers (1)

tanaydin
tanaydin

Reputation: 5296

Try urlencodefunction. Documentation here.

https://docs.python.org/2/library/urllib.html#urllib.urlencode

Upvotes: 2

Related Questions