我正在研究shopware API当我正在解析的URL时 喜欢
http://192.168.0.100/shopware531/api
并给我一个错误:〜
connection_type = SCHEME_TO_CONNECTION[scheme]
KeyError: u' http'
使用
def buildHttpQuery(self, taxonomy, parameters):
if taxonomy.startswith('/'):
taxonomy = taxonomy[1:]
if not self.baseurl.endswith('/'):
self.baseurl += '/'
url = urljoin(self.baseurl, taxonomy)
url_parts = list(urlparse(url))
query = dict(parse_qsl(url_parts[4]))
query.update(parameters)
url_parts[4] = urlencode(query)
url = urlunparse(url_parts)
return url
答案 0 :(得分:1)
我有类似的问题,但是有字节。我有类似b"https://google.com"
的链接,并且我使用httplib2.request(str(link))
,因为此请求需要字符串而不是字节。稍后在调试器上,我看到str函数将b'https://google.com'
转换为b'https://google.com'
并导致KeyError。因此,在使用b'https://google.com'.decode('utf-8')
之后,它可以工作。