當前位置: 首頁>>代碼示例>>Python>>正文


Python http.parse_qs方法代碼示例

本文整理匯總了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) 
開發者ID:txamqp,項目名稱:txamqp,代碼行數:26,代碼來源:endpoint.py

示例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")) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:14,代碼來源:test_http.py

示例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")) 
開發者ID:kuri65536,項目名稱:python-for-android,代碼行數:11,代碼來源:test_http.py


注:本文中的twisted.web.http.parse_qs方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。