s = "url=%2F&email=imtesting%40tempmail.com&password=hereispassword"
print urllib.unquote(s)
>>> url=/&email=imtesting@tempmail.com&password=hereispassword
为了将每一个标点和控制符都“转换”为词
python正则模块使用:
w = re.split(r'(\W)','<script>alert(123)</script>')
>>> import re
>>> w = re.split(r'(\W)','<script>alert(123)</script>')
>>> w
['', '<', 'script', '>', 'alert', '(', '123', ')', '', '<', '', '/', 'script', '>', '']
然后再删掉其中的空格
>>> def not_empty(w):
... return w and w.strip()
...
>>> list(filter(not_empty,w))
['<', 'script', '>', 'alert', '(', '123', ')', '<', '/', 'script', '>']