我正在尝试在提交之前对这个字符串进行 urlencode。
queryString = 'eventName=' + evt.fields["eventName"] + '&' + 'eventDescription=' + evt.fields["eventDescription"];
最佳答案
Python 2
您要查找的是 urllib.quote_plus
:
safe_string = urllib.quote_plus('string_of_characters_like_these:$#@=?%^Q^$')
#Value: 'string_of_characters_like_these%3A%24%23%40%3D%3F%25%5EQ%5E%24'
Python 3
在 Python 3 中,urllib
包已分解为更小的组件。您将使用 urllib.parse.quote_plus
(注意 parse
子模块)
import urllib.parse
safe_string = urllib.parse.quote_plus(...)
关于python - 如何在 Python 中对查询字符串进行 urlencode?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5607551/