# 生成指定语言的测试URL
def gen_language_url(url, language_dict):
"""
:param url: 测试url,中文
:param language_dict: 要生成的指定语言列表
:return: 语言 及 对应的URL
"""
d = {}
for key, value in language_dict.items():
new_url = url.replace("ch", value)
d[key] = new_url
for key, value in d.items():
print(key, value)
if __name__ == '__main__':
url_pa = "https://www.baidu.com/ch/ccccc"
language_dict_pa = {"英语": "en", "土耳其语": "tr"}
gen_language_url(url_pa, language_dict_pa)
需求:给一个中文的测试URL,生成指定多种语言的测试URL