标签:end class url append urlencode for res lib int
import urllib.parse
def a(name, **kwargs):
return b(**kwargs)
def b(**kwargs):
return c(**kwargs)
def c(**kwargs):
args = []
for k, v in kwargs.items():
para = v.encode("utf-8") if isinstance(v, str) else str(v)
args.append("{0}={1}".format(k, urllib.parse.quote(para)))
return "&".join(args)
res = a("name", a=1, b=2, c=3)
print(res)
# 输出结果
a=1&b=2&c=3
网络数据传输--编码转换,不定长参数传递,字符串拼接,URLencode编码
标签:end class url append urlencode for res lib int
原文地址:https://www.cnblogs.com/yblackd/p/13051691.html