如果连接直接这样写,看上去很直观,不过参数替换不是很方便,而且看着不舒服

https://www.mysite.com/?sortField=%E4%BA%BA%E5%B7%A5%E6%99%BA%E8%83%BD&pageIndex=3&pageSize=20

可以使用如下方式美化代码

from urllib.parse import urlencode 

url = "https://www.mysite.com/"

parameter = {
    "pageSize": 20,
    "sortField": "人工智能",
    "pageIndex": 3
}

data = urlencode(parameter)

print(url + "?" + data)
# https://www.mysite.com/?sortField=%E4%BA%BA%E5%B7%A5%E6%99%BA%E8%83%BD&pageIndex=3&pageSize=20