相关疑难解决方法(0)

Python字典到URL参数

我试图将Python字典转换为字符串以用作URL参数.我确信有一种更好,更Pythonic的方式来做到这一点.它是什么?

x = ""
for key, val in {'a':'A', 'b':'B'}.items():
    x += "%s=%s&" %(key,val)
x = x[:-1]
Run Code Online (Sandbox Code Playgroud)

python dictionary url-parameters

113
推荐指数
3
解决办法
7万
查看次数

标签 统计

dictionary ×1

python ×1

url-parameters ×1