使用cgi.parse_qs()
后,如何将结果(字典)转换回查询字符串?寻找类似于 urllib.urlencode()
的东西。
最佳答案
Python 3
urllib.parse.urlencode(query, doseq=False, [...])
Convert a mapping object or a sequence of two-element tuples, which may contain str or bytes objects, to a percent-encoded ASCII text string.
dict
是一个映射。
旧版 Python
urllib.urlencode
(query
[,doseq
])
Convert a mapping object or a sequence of two-element tuples to a “percent-encoded” string... a series ofkey=value
pairs separated by'&'
characters...
关于python - 如何在 Python 中将字典转换为查询字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7801991/