发布网友 发布时间:2022-04-30 07:15
共1个回答
热心网友 时间:2022-04-18 06:14
from urllib.parse import quote
main_url = "https://ke.baidu.com/item"
universitys = ["北京航空航天大学", "清华大学", "武汉大学", "华中科技大学"]
for university in universitys:
url = f"{main_url}/{quote(university)}"
print(url)
结果如下:
https://ke.baidu.com/item/%E5%8C%97%E4%BA%AC%E8%88%AA%E7%A9%BA%E8%88%AA%E5%A4%A9%E5%A4%A7%E5%AD%A6
https://ke.baidu.com/item/%E6%B8%85%E5%8D%8E%E5%A4%A7%E5%AD%A6
https://ke.baidu.com/item/%E6%AD%A6%E6%B1%89%E5%A4%A7%E5%AD%A6
https://ke.baidu.com/item/%E5%8D%8E%E4%B8%AD%E7%A7%91%E6%8A%80%E5%A4%A7%E5%AD%A6