1

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?

Ranga Sarin
  • 169
  • 1
  • 5
  • 14
  • 1
    http://stackoverflow.com/questions/931423/is-there-a-python-equivalent-to-the-php-function-htmlspecialchars – Brett Sep 01 '16 at 22:49

1 Answers1

2

Try urlencodefunction. Documentation here.

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

tanaydin
  • 5,171
  • 28
  • 45