我有一个基本URL。
BASE_URL = 'https://api.github.com/licenses'
我想基于附加到基本URL的搜索词(Ex-mit)创建一个新的URL。
NEW_URL = 'https://api.github.com/licenses/mit'
我正在使用请求库来构建和调用URL,如下所示。
from requests.compat import urljoin
base_url = 'https://api.github.com/licenses'
new_url = urljoin(base_url, 'mit')
print new_url
但是当我打印new_url时,它弄乱了URL。
https://api.github.com/mit
我不确定如何解决此问题。
/
在基本网址的末尾添加。
BASE_URL = 'https://api.github.com/licenses/'
否则,可能会将许可证视为文件名。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句