本文整理匯總了Python中twisted.web.http.parse_qs方法的典型用法代碼示例。如果您正苦於以下問題:Python http.parse_qs方法的具體用法?Python http.parse_qs怎麽用?Python http.parse_qs使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類twisted.web.http
的用法示例。
在下文中一共展示了http.parse_qs方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: from_uri
# 需要導入模塊: from twisted.web import http [as 別名]
# 或者: from twisted.web.http import parse_qs [as 別名]
def from_uri(cls, reactor, uri):
"""Return an AMQEndpoint instance configured with the given AMQP uri.
@see: https://www.rabbitmq.com/uri-spec.html
"""
uri = URI.fromBytes(uri.encode(), defaultPort=5672)
kwargs = {}
host = uri.host.decode()
if "@" in host:
auth, host = uri.netloc.decode().split("@")
username, password = auth.split(":")
kwargs.update({"username": username, "password": password})
vhost = uri.path.decode()
if len(vhost) > 1:
vhost = vhost[1:] # Strip leading "/"
kwargs["vhost"] = vhost
params = parse_qs(uri.query)
kwargs.update({name.decode(): value[0].decode() for name, value in params.items()})
if "heartbeat" in kwargs:
kwargs["heartbeat"] = int(kwargs["heartbeat"])
return cls(reactor, host, uri.port, **kwargs)
示例2: testParseqs
# 需要導入模塊: from twisted.web import http [as 別名]
# 或者: from twisted.web.http import parse_qs [as 別名]
def testParseqs(self):
self.assertEqual(
cgi.parse_qs(b"a=b&d=c;+=f"),
http.parse_qs(b"a=b&d=c;+=f"))
self.assertRaises(
ValueError, http.parse_qs, b"blah", strict_parsing=True)
self.assertEqual(
cgi.parse_qs(b"a=&b=c", keep_blank_values=1),
http.parse_qs(b"a=&b=c", keep_blank_values=1))
self.assertEqual(
cgi.parse_qs(b"a=&b=c"),
http.parse_qs(b"a=&b=c"))
示例3: testParseqs
# 需要導入模塊: from twisted.web import http [as 別名]
# 或者: from twisted.web.http import parse_qs [as 別名]
def testParseqs(self):
self.failUnlessEqual(cgi.parse_qs("a=b&d=c;+=f"),
http.parse_qs("a=b&d=c;+=f"))
self.failUnlessRaises(ValueError, http.parse_qs, "blah",
strict_parsing = 1)
self.failUnlessEqual(cgi.parse_qs("a=&b=c", keep_blank_values = 1),
http.parse_qs("a=&b=c", keep_blank_values = 1))
self.failUnlessEqual(cgi.parse_qs("a=&b=c"),
http.parse_qs("a=&b=c"))