Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/279.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
python urllib.parse不';不要保留路径部分_Python - Fatal编程技术网

python urllib.parse不';不要保留路径部分

python urllib.parse不';不要保留路径部分,python,Python,这是预期的吗? 如何保留/api部分?在第一段末尾使用正斜杠: In [26]: urllib.parse.urljoin("http://example.com/api", "bcd/efg") Out[26]: 'http://example.com/bcd/efg' >>> import urllib.parse >>> urllib.parse.urljoin("http://example.com/api/", "bcd/efg") 'http:

这是预期的吗?
如何保留
/api
部分?

在第一段末尾使用正斜杠:

In [26]: urllib.parse.urljoin("http://example.com/api", "bcd/efg")
Out[26]: 'http://example.com/bcd/efg'

>>> import urllib.parse
>>> urllib.parse.urljoin("http://example.com/api/", "bcd/efg")
'http://example.com/api/bcd/efg'