Python parse.urlencode方法代码示例

本文整理汇总了Python中urllib.parse.urlencode方法的典型用法代码示例。如果您正苦于以下问题:Python parse.urlencode方法的具体用法?Python parse.urlencode怎么用?Python parse.urlencode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在模块urllib.parse的用法示例。

在下文中一共展示了parse.urlencode方法的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: lmgtfy

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlencode [as 别名]
def lmgtfy(self, ctx: Context, *args: str):
        """
        Returns a LMGTFY URL for a given user argument.
        """
        # Creates a lmgtfy.com url for the given query.
        request_data = {
            "q": " ".join(arg for arg in args if not arg.startswith("-")),
            "ie": int("-ie" in args),
        }
        url = "https://lmgtfy.com/?" + urlencode(request_data)
        await ctx.send(url)
        if "-d" in args:
            await ctx.message.delete()
    # Ratelimit to one use per user every minute and 4 usages per minute per channel 
开发者ID:CyberDiscovery,项目名称:cyberdisc-bot,代码行数:19,代码来源:fun.py


示例2: get_subscribe_authorize_url

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlencode [as 别名]
def get_subscribe_authorize_url(self, scene, template_id, redirect_url, reserved=None):
        """
        构造请求用户授权的url
        详情请参阅:
        https://mp.weixin.qq.com/wiki?id=mp1500374289_66bvB
        :param scene: 订阅场景值,开发者可以填0-10000的整形值,用来标识订阅场景值
        :type scene: int
        :param template_id: 订阅消息模板ID,登录公众平台后台,在接口权限列表处可查看订阅模板ID
        :param redirect_url: 授权后重定向的回调地址
        :param reserved: 用于保持请求和回调的状态,授权请后原样带回给第三方。该参数可用于防止csrf攻击。若不指定则随机生成。
        """
        if reserved is None:
            reserved = random_string()
        base_url = "https://mp.weixin.qq.com/mp/subscribemsg"
        params = [
            ("action", "get_confirm"),
            ("appid", self.appid),
            ("scene", scene),
            ("template_id", template_id),
            ("redirect_url", redirect_url),
            ("reserved", reserved),
        ]
        encoded_params = urlencode(params)
        return f"{base_url}?{encoded_params}#wechat_redirect" 
开发者ID:wechatpy,项目名称:wechatpy,代码行数:27,代码来源:message.py


示例3: __init__

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlencode [as 别名]
def __init__(
    self,
    params,
    site_api='https://maps.googleapis.com/maps/api/streetview',
    site_metadata='https://maps.googleapis.com/maps/api/streetview/metadata'):
    # (params) Set default params
    defaults = {
      'size': '640x640'
    }
    for i in range(len(params)):
      for k in defaults:
        if k not in params[i]:
          params[i][k] = defaults[k]
    self.params = params
    # (image) Create image api links from parameters
    self.links = [site_api + '?' + urlencode(p) for p in params]
    # (metadata) Create metadata api links and data from parameters
    self.metadata_links = [site_metadata + '?' + urlencode(p) for p in params]
    self.metadata = [requests.get(url, stream=True).json() for url in self.metadata_links] 
开发者ID:rrwen,项目名称:google_streetview,代码行数:24,代码来源:api.py


示例4: get_mood_url

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlencode [as 别名]
def get_mood_url(self):
        url='https://h5.qzone.qq.com/proxy/domain/taotao.qq.com/cgi-bin/emotion_cgi_msglist_v6?'
        params = {
              "sort":0,
                  "start":0,
              "num":20,
            "cgi_host": "http://taotao.qq.com/cgi-bin/emotion_cgi_msglist_v6",
              "replynum":100,
              "callback":"_preloadCallback",
              "code_version":1,
            "inCharset": "utf-8",
            "outCharset": "utf-8",
            "notice": 0,
              "format":"jsonp",
              "need_private_comment":1,
              "g_tk": self.g_tk
              }
        url = url + parse.urlencode(params)
        return url 
开发者ID:nanxung,项目名称:QQ_zone,代码行数:21,代码来源:qq_spider.py


示例5: post

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlencode [as 别名]
def post(self, payload, request_par):
        data = parse.urlencode(request_par).encode()
        if self.UserAgent != None:
            req = Request(
                    self.target_url,
                    data=data,
                    headers={"User-Agent":self.UserAgent})
            conn = urlopen(req, timeout=self.TimeOut)
        else:
            conn = urlopen(self.target_url,
                    data=data,
                    timeout=self.TimeOut)
        html = conn.read().decode("utf-8")
        page_size = len(html)
        if self.verbose == True:
            print(" [+] Source code got from %s" % payload)
            print("----START" + "-"*71)
            print(html)
            print("----END" + "-"*73)
        return(self.target_url, page_size, html, payload) 
开发者ID:fnk0c,项目名称:dot2moon,代码行数:26,代码来源:connection.py


示例6: test_get_uptoken

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlencode [as 别名]
def test_get_uptoken(self):
        params = {'bucket': 'jike'}
        success_reponse = {'uptoken': 'token'}
        responses.add(responses.GET, constants.ENDPOINTS['picture_uptoken'],
                      json=success_reponse, status=200)
        responses.add(responses.GET, constants.ENDPOINTS['picture_uptoken'],
                      status=404)
        # success call
        result = utils.get_uptoken()
        self.assertEqual(result, 'token')
        self.assertEqual(len(responses.calls), 1)
        self.assertEqual(responses.calls[0].request.url,
                         constants.ENDPOINTS['picture_uptoken'] + '?' + urlencode(params))
        self.assertEqual(responses.calls[0].response.json(), success_reponse)
        # failed call
        with self.assertRaises(requests.HTTPError) as cm:
            utils.get_uptoken()
        self.assertEqual(len(responses.calls), 2)
        self.assertEqual(cm.exception.response.status_code, 404) 
开发者ID:Sorosliu1029,项目名称:Jike-Metro,代码行数:21,代码来源:test_utils.py


示例7: _http_request

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlencode [as 别名]
def _http_request(self, url: str, headers: dict = None, payload: dict = None) -> Response:
        if not self._session:
            raise RetsClientError('Session not instantiated. Call .login() first')
        request_headers = {
            **(headers or {}),
            'User-Agent': self.user_agent,
            'RETS-Version': self.rets_version,
            'RETS-UA-Authorization': self._rets_ua_authorization()
        }
        if self._use_get_method:
            if payload:
                url = '%s?%s' % (url, urlencode(payload))
            response = self._session.get(url, auth=self._http_auth, headers=request_headers)
        else:
            response = self._session.post(url, auth=self._http_auth, headers=request_headers, data=payload)
        response.raise_for_status()
        self._rets_session_id = self._session.cookies.get('RETS-Session-ID', '')
        return response 
开发者ID:opendoor-labs,项目名称:rets,代码行数:23,代码来源:client.py


示例8: _load

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlencode [as 别名]
def _load(self, request: Request) -> tuple:
        params = ('&' + urlencode(request.params)) if request.params else ''
        url = request.url + params
        item = self._cache.get(url, None)
        if item is None:
            return None, None
        vary_key = self._vary_key(request, item[0])
        cached = item[1].get(vary_key, None)
        if cached is not None:
            response = cached['response']
            deque_item = (url, vary_key)
            if self._cc_fresh(cached):
                self._update_usage(deque_item)
                return response, None
            elif self._has_etag(cached):
                self._update_usage(deque_item)
                return response, cached['etag']
            elif self.max_size is not None:
                self._deque.remove(deque_item)
        return None, None 
开发者ID:felix-hilden,项目名称:tekore,代码行数:26,代码来源:extending.py


示例9: stations

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlencode [as 别名]
def stations(self, **params):
        """Get list of US weather stations and their metadata.
        Response in this method should not be modified.
        In this way, we can keep track of changes made by NOAA through
        functional tests @todo(paulokuong) later on.
        Args:
            station_id (str[optional]): station id.
            state (str[optional]): 2 letters state code.
            limit (int[optional]): limit of results.
        Returns:
            json: json response from api.
        """
        if len(params) > 0:
            if 'station_id' in params:
                params['id'] = params['station_id']
                del params['station_id']
            return self.make_get_request(
                "/stations?{query_string}".format(
                    query_string=urlencode(params)),
                end_point=self.DEFAULT_END_POINT)
        return self.make_get_request(
            "/stations", end_point=self.DEFAULT_END_POINT) 
开发者ID:paulokuong,项目名称:noaa,代码行数:26,代码来源:noaa.py


示例10: request_encode_url

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlencode [as 别名]
def request_encode_url(self, method, url, fields=None, headers=None,
                           **urlopen_kw):
        """
        Make a request using :meth:`urlopen` with the ``fields`` encoded in
        the url. This is useful for request methods like GET, HEAD, DELETE, etc.
        """
        if headers is None:
            headers = self.headers
        extra_kw = {'headers': headers}
        extra_kw.update(urlopen_kw)
        if fields:
            url += '?' + urlencode(fields)
        return self.urlopen(method, url, **extra_kw) 
开发者ID:MediaBrowser,项目名称:plugin.video.emby,代码行数:18,代码来源:request.py


示例11: report

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlencode [as 别名]
def report(self,
               hash=None,
               format=None):
        self.__clear_response()
        request_uri = '/publicapi/get/report'
        query = {}
        query['apikey'] = self.api_key
        if hash is not None:
            query['hash'] = hash
        if format is not None:
            query['format'] = format
        response = self.__api_request(request_uri=request_uri,
                                      body=urlencode(query))
        if not response:
            raise PanWFapiError(self._msg)
        if not self.__set_response(response):
            raise PanWFapiError(self._msg) 
开发者ID:PaloAltoNetworks,项目名称:terraform-templates,代码行数:23,代码来源:wfapi.py


示例12: verdict

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlencode [as 别名]
def verdict(self,
                hash=None):
        self.__clear_response()
        request_uri = '/publicapi/get/verdict'
        query = {}
        query['apikey'] = self.api_key
        if hash is not None:
            query['hash'] = hash
        response = self.__api_request(request_uri=request_uri,
                                      body=urlencode(query))
        if not response:
            raise PanWFapiError(self._msg)
        if not self.__set_response(response):
            raise PanWFapiError(self._msg) 
开发者ID:PaloAltoNetworks,项目名称:terraform-templates,代码行数:20,代码来源:wfapi.py


示例13: verdicts_changed

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlencode [as 别名]
def verdicts_changed(self,
                         date=None):
        self.__clear_response()
        request_uri = '/publicapi/get/verdicts/changed'
        query = {}
        query['apikey'] = self.api_key
        if date is not None:
            query['date'] = date
        response = self.__api_request(request_uri=request_uri,
                                      body=urlencode(query))
        if not response:
            raise PanWFapiError(self._msg)
        if not self.__set_response(response):
            raise PanWFapiError(self._msg) 
开发者ID:PaloAltoNetworks,项目名称:terraform-templates,代码行数:20,代码来源:wfapi.py


示例14: sample

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlencode [as 别名]
def sample(self,
               hash=None):
        self.__clear_response()
        request_uri = '/publicapi/get/sample'
        query = {}
        query['apikey'] = self.api_key
        if hash is not None:
            query['hash'] = hash
        response = self.__api_request(request_uri=request_uri,
                                      body=urlencode(query))
        if not response:
            raise PanWFapiError(self._msg)
        if not self.__set_response(response):
            raise PanWFapiError(self._msg) 
开发者ID:PaloAltoNetworks,项目名称:terraform-templates,代码行数:20,代码来源:wfapi.py


示例15: pcap

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlencode [as 别名]
def pcap(self,
             hash=None,
             platform=None):
        self.__clear_response()
        request_uri = '/publicapi/get/pcap'
        query = {}
        query['apikey'] = self.api_key
        if hash is not None:
            query['hash'] = hash
        if platform is not None:
            query['platform'] = platform
        response = self.__api_request(request_uri=request_uri,
                                      body=urlencode(query))
        if not response:
            raise PanWFapiError(self._msg)
        if not self.__set_response(response):
            raise PanWFapiError(self._msg) 
开发者ID:PaloAltoNetworks,项目名称:terraform-templates,代码行数:23,代码来源:wfapi.py


示例16: http_request

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlencode [as 别名]
def http_request(url, data=None, timeout=30):
    log.debug("Requesting URL: %s" % url)
    data = urlencode(data).encode('utf8') if data else None
    try:
        response = urlopen(url, data=data, timeout=timeout)
        return {'success':True, 'response':response, 'url':url}
    except Exception as err:
        log.error("Error requesting URL: %s; %s" % (url, err))
        return {'success':False, 'error':err, 'url':url} 
开发者ID:pkkid,项目名称:pkmeter,代码行数:11,代码来源:utils.py


示例17: test_authentication_error_response_calls_to_error_view_if_set

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlencode [as 别名]
def test_authentication_error_response_calls_to_error_view_if_set(self):
        state = 'test_tate'
        error_response = {'error': 'invalid_request', 'error_description': 'test error'}
        authn = self.init_app()
        error_view_mock = self.get_view_mock()
        authn.error_view(error_view_mock)
        with self.app.test_request_context('/redirect_uri?{error}&state={state}'.format(error=urlencode(error_response),
                                                                                        state=state)):
            UserSession(flask.session, self.PROVIDER_NAME)
            flask.session['state'] = state
            flask.session['nonce'] = 'test_nonce'
            result = authn._handle_authentication_response()
        self.assert_view_mock(error_view_mock, result)
        error_view_mock.assert_called_with(**error_response) 
开发者ID:zamzterz,项目名称:Flask-pyoidc,代码行数:17,代码来源:test_flask_pyoidc.py


示例18: test_authentication_error_response_returns_default_error_if_no_error_view_set

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlencode [as 别名]
def test_authentication_error_response_returns_default_error_if_no_error_view_set(self):
        state = 'test_tate'
        error_response = {'error': 'invalid_request', 'error_description': 'test error', 'state': state}
        authn = self.init_app(dict(provider_configuration_info={'issuer': self.PROVIDER_BASEURL},
                                   client_registration_info=dict(client_id='abc', client_secret='foo')))
        with self.app.test_request_context('/redirect_uri?{}'.format(urlencode(error_response))):
            UserSession(flask.session, self.PROVIDER_NAME)
            flask.session['state'] = state
            flask.session['nonce'] = 'test_nonce'
            response = authn._handle_authentication_response()
        assert response == "Something went wrong with the authentication, please try to login again." 
开发者ID:zamzterz,项目名称:Flask-pyoidc,代码行数:13,代码来源:test_flask_pyoidc.py


示例19: setUp

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlencode [as 别名]
def setUp(self):
        super().setUp()
        self.query_string_dict = {
            "zmirror": "love_lucia",
            "zhi": "撒吱吱pr(顺便测试中文)",
        }
        self.query_string = urlencode(self.query_string_dict)  # type: str
        self.verify_page_url = self.url(
            "/ip_ban_verify_page?origin=aHR0cDovL2Iud"
            "GVzdC5jb20vZ2V0P3ptaXJyb3I9bG92ZV9sdWNpY"
            "SZ6aGk95pKS5ZCx5ZCxcHIo6aG65L6_5rWL6K-V5"
            "Lit5paHKQ=="
        )  # type: str
        self.origin = self.verify_page_url[self.verify_page_url.find("origin=") + 7:]  # type: str 
开发者ID:aploium,项目名称:zmirror,代码行数:17,代码来源:test_verification.py


示例20: list_submissions

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlencode [as 别名]
def list_submissions(self, id=None, student=None, grader=None):
        """
        Returns the list of submissions associated with an assignment, which
        optionally can be filtered according to a specific submitting `student`
        or a `grader`.
        """
        _class_type = type(self)
        id = self._get_id(id=id)
        endpoint = "{}/submissions".format(self.instance_endpoint_by_id(id=id))
        endpoint_params = {}
        if student != None:
            # Filter according to a specific student (will be URL-quoted later)
            endpoint_params["student"] = student
        if grader != None:
            # Filter according to a specific grader (will be URL-quoted later)
            endpoint_params["grader"] = grader
        if len(endpoint_params) > 0:
            endpoint += "?{}".format(_urlencode(endpoint_params))
        ret = self._requestor._request(
            endpoint=endpoint,
            method="GET",
        )
        if ret.status_code == 200:
            # Returns a list of all submissions
            return list(map(
                lambda kwargs: _submissions.Submissions(**kwargs),
                ret.json))
# ============================================================================= 
开发者ID:codepost-io,项目名称:codepost-python,代码行数:37,代码来源:assignments.py


示例21: avatar

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlencode [as 别名]
def avatar(self):
        email = self.email.lower()
        hash = md5(email.encode()).hexdigest()
        default = f'https://api.adorable.io/avatars/256/{email}.png'
        params = urlencode({'d': default, 's': 512})
        return f'https://www.gravatar.com/avatar/{hash}?{params}' 
开发者ID:cuducos,项目名称:django-ajax-contacts,代码行数:8,代码来源:models.py


示例22: test_avatar

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlencode [as 别名]
def test_avatar(self):
        email = self.contact.email.lower()
        hash = md5(email.encode()).hexdigest()
        params = urlencode({
            'd': f'https://api.adorable.io/avatars/256/{email}.png',
            's': 512
        })
        expected = f'https://www.gravatar.com/avatar/{hash}?{params}'
        self.assertEqual(expected, self.contact.avatar()) 
开发者ID:cuducos,项目名称:django-ajax-contacts,代码行数:11,代码来源:test_contact_model.py


示例23: get_authenticated_user

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlencode [as 别名]
def get_authenticated_user(self, code, callback):
        http = self.get_auth_http_client()
        body = urllib_parse.urlencode({
            'code': code,
            'client_id': config['github']['client_id'],
            'client_secret': config['github']['client_secret'],
        })
        http.fetch(self._OAUTH_ACCESS_TOKEN_URL,
                   functools.partial(self._on_access_token, callback),
                   method="POST", headers={'Content-Type': 'application/x-www-form-urlencoded'},
                   body=body) 
开发者ID:tuna,项目名称:fishroom,代码行数:14,代码来源:oauth.py


示例24: authenticated

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlencode [as 别名]
def authenticated(method):
    @functools.wraps(method)
    def wrapper(self, *args, **kwargs):
        if config.get('github', False) and not self.current_user:
            if self.request.method in ("GET", "HEAD"):
                url = self.get_login_url()
                self.redirect(url + "?" + urlencode(dict(next=self.request.uri)))
                return
            raise tornado.web.HTTPError(403)
        return method(self, *args, **kwargs)
    return wrapper 
开发者ID:tuna,项目名称:fishroom,代码行数:13,代码来源:handlers.py


示例25: _build_payload

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlencode [as 别名]
def _build_payload(self):
        checksum_body = hashlib.sha256(self._requestBody.encode('latin-1')).digest()
        str_checksum_body = checksum_body.decode('latin-1')
        parts = [self._requestTimestamp, urlencode(self._sort_dict(self._requestParameters), True), str_checksum_body]
        return "\n".join(parts) 
开发者ID:messagebird,项目名称:python-rest-api,代码行数:7,代码来源:signed_request.py


示例26: make_test_headers_path_and_query_string

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlencode [as 别名]
def make_test_headers_path_and_query_string(
    app: "Quart",
    path: str,
    headers: Optional[Union[dict, Headers]] = None,
    query_string: Optional[dict] = None,
) -> Tuple[Headers, str, bytes]:
    """Make the headers and path with defaults for testing.
    Arguments:
        app: The application to test against.
        path: The path to request. If the query_string argument is not
            defined this argument will be partitioned on a '?' with
            the following part being considered the query_string.
        headers: Initial headers to send.
        query_string: To send as a dictionary, alternatively the
            query_string can be determined from the path.
    """
    if headers is None:
        headers = Headers()
    elif isinstance(headers, Headers):
        headers = headers
    elif headers is not None:
        headers = Headers(headers)
    headers.setdefault("Remote-Addr", "127.0.0.1")
    headers.setdefault("User-Agent", "Quart")
    headers.setdefault("host", app.config["SERVER_NAME"] or "localhost")
    if "?" in path and query_string is not None:
        raise ValueError("Query string is defined in the path and as an argument")
    if query_string is None:
        path, _, query_string_raw = path.partition("?")
    else:
        query_string_raw = urlencode(query_string, doseq=True)
    query_string_bytes = query_string_raw.encode("ascii")
    return headers, unquote(path), query_string_bytes 
开发者ID:pgjones,项目名称:quart,代码行数:36,代码来源:testing.py


示例27: make_test_body_with_headers

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlencode [as 别名]
def make_test_body_with_headers(
    data: Optional[AnyStr] = None,
    form: Optional[dict] = None,
    json: Any = sentinel,
    app: Optional["Quart"] = None,
) -> Tuple[bytes, Headers]:
    """Make the body bytes with associated headers.
    Arguments:
        data: Raw data to send in the request body.
        form: Data to send form encoded in the request body.
        json: Data to send json encoded in the request body.
    """
    if [json is not sentinel, form is not None, data is not None].count(True) > 1:
        raise ValueError("Quart test args 'json', 'form', and 'data' are mutually exclusive")
    request_data = b""
    headers = Headers()
    if isinstance(data, str):
        request_data = data.encode("utf-8")
    elif isinstance(data, bytes):
        request_data = data
    if json is not sentinel:
        request_data = dumps(json, app=app).encode("utf-8")
        headers["Content-Type"] = "application/json"
    if form is not None:
        request_data = urlencode(form).encode("utf-8")
        headers["Content-Type"] = "application/x-www-form-urlencoded"
    return request_data, headers 
开发者ID:pgjones,项目名称:quart,代码行数:36,代码来源:testing.py


示例28: test_request_values

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlencode [as 别名]
def test_request_values() -> None:
    request = Request(
        "GET",
        "http",
        "/",
        b"a=b&a=c",
        Headers({"host": "quart.com", "Content-Type": "application/x-www-form-urlencoded"}),
        "",
        "1.1",
        send_push_promise=no_op_push,
    )
    request.body.append(urlencode({"a": "d"}).encode())
    request.body.set_complete()
    assert (await request.values).getlist("a") == ["b", "c", "d"] 
开发者ID:pgjones,项目名称:quart,代码行数:16,代码来源:test_request.py


示例29: urlencode

# 需要导入模块: from urllib import parse [as 别名]
# 或者: from urllib.parse import urlencode [as 别名]
def urlencode(stuff) :
	if isinstance(stuff, dict):
		return urlparse.urlencode(stuff)
	elif isinstance(stuff, str):
		return urlparse.quote(stuff)
## url解码 
开发者ID:jojoin,项目名称:cutout,代码行数:10,代码来源:util.py



注:本文中的urllib.parse.urlencode方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。