当前位置: 首页>>代码示例>>Python>>正文


Python urllib._quote函数代码示例

本文整理汇总了Python中urllib._quote函数的典型用法代码示例。如果您正苦于以下问题:Python _quote函数的具体用法?Python _quote怎么用?Python _quote使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: quote

def quote(value, safe="/"):
    """
    Patched version of urllib.quote that encodes utf8 strings before quoting
    """
    if isinstance(value, unicode):
        value = value.encode("utf8")
    return _quote(value, safe)
开发者ID:edwardt,项目名称:swift,代码行数:7,代码来源:client.py

示例2: quote

def quote(s, safe=b'/'):
    s = _quote(s.encode('utf-8'), safe)
    # PY3 always returns unicode.  PY2 may return either, depending on whether
    # it had to modify the string.
    if isinstance(s, bytes_type):
        s = s.decode('utf-8')
    return s
开发者ID:Acidburn0zzz,项目名称:firefox-flicks,代码行数:7,代码来源:common.py

示例3: quote

def quote(s, safe=b"/"):
    s = s.encode("utf-8") if isinstance(s, unicode_type) else s
    s = _quote(s, safe)
    # PY3 always returns unicode.  PY2 may return either, depending on whether
    # it had to modify the string.
    if isinstance(s, bytes_type):
        s = s.decode("utf-8")
    return s
开发者ID:AnVed,项目名称:Online-magazine,代码行数:8,代码来源:common.py

示例4: quote

def quote(string):
    try:
        if type(string) is unicode:
            string = string.encode('utf-8')
        return _quote(string)
    except:
        print 'quoted string is:', string
        raise
开发者ID:ajiexw,项目名称:old-zarkpy,代码行数:8,代码来源:site_helper.py

示例5: quote

def quote(value, safe='/'):
    """
    Patched version of urllib.quote that encodes utf8 strings before quoting
    """
    value = encode_utf8(value)
    if isinstance(value, str):
        return _quote(value, safe)
    else:
        return value
开发者ID:meitham,项目名称:python-swiftclient,代码行数:9,代码来源:client.py

示例6: quote

def quote(text, *args, **kwargs):
	t = type(text)
	if t is str:
		converted_text = text
	elif t is unicode:
		converted_text = str(text.encode('utf-8'))
	else:
		try:
			converted_text = str(text)
		except:
			converted_text = text
	return _quote(converted_text, *args, **kwargs)
开发者ID:OneSecure,项目名称:bingimage,代码行数:12,代码来源:utils.py

示例7: quote

def quote(value, safe='/'):
    if isinstance(value, unicode):
        (value, _len) = utf8_encoder(value, 'replace')
    (valid_utf8_str, _len) = utf8_decoder(value, 'replace')
    return _quote(valid_utf8_str.encode('utf-8'), safe)
开发者ID:lanweichang,项目名称:oio-sds,代码行数:5,代码来源:utils.py

示例8: _quote

try:
    import httplib
except ImportError:
    import http.client as httplib

try:
    from urllib import quote as _quote
    from urllib import quote as _quote_from_bytes
    from urllib import unquote as unquote_to_bytes
except ImportError:
    from urllib.parse import quote as _quote
    from urllib.parse import quote_from_bytes as _quote_from_bytes
    from urllib.parse import unquote_to_bytes

quote = lambda s: _quote(s, safe='')
quote_from_bytes = lambda s: _quote_from_bytes(s, safe='')

try:
    import cPickle as pickle
except ImportError:
    import pickle

import json

KT_HTTP_HEADER = {'Content-Type' : 'text/tab-separated-values; colenc=U'}

def _dict_to_tsv(kv_dict):
    lines = []
    for k, v in kv_dict.items():
        quoted = quote_from_bytes(v) if isinstance(v, bytes) else quote(str(v))
开发者ID:alticelabs,项目名称:python-kyototycoon-ng,代码行数:30,代码来源:kt_http.py

示例9: quote

def quote(value):
    value = value.encode('utf8', errors='ignore') if isinstance(value, unicode) else str(value)
    return _quote(value, safe='')
开发者ID:Saiy,项目名称:pyes,代码行数:3,代码来源:__init__.py

示例10: _quote

# Copyright 2011, Toru Maesaka
#
# Redistribution and use of this source code is licensed under
# the BSD license. See COPYING file for license description.

import base64
import httplib
import struct
import time
import kt_error
try:
    from percentcoding import quote, unquote
except ImportError:
    from urllib import quote as _quote
    from urllib import unquote
    quote = lambda s: _quote(s, safe="")

try:
    import cPickle as pickle
except ImportError:
    import pickle

# Stick with URL encoding for now. Eventually run a benchmark
# to evaluate what the most approariate encoding algorithm is.
KT_HTTP_HEADER = {
  'Content-Type' : 'text/tab-separated-values; colenc=U',
}

KT_PACKER_CUSTOM = 0
KT_PACKER_PICKLE = 1
KT_PACKER_JSON   = 2
开发者ID:klpauba,项目名称:python-kyototycoon,代码行数:31,代码来源:kt_http.py

示例11: quote

def quote(s, safe='/'):
    if isinstance(s, unicode):
        s = s.encode('utf-8', 'ignore') # hope we're using utf-8!
    return _quote(s, safe).replace('/', encoded_slash)
开发者ID:jonallengriffin,项目名称:toolbox,代码行数:4,代码来源:handlers.py

示例12: quote

def quote(*l):
    return tuple(_quote(unicodeToStr(s)) for s in l) if len(l) != 1 else _quote(unicodeToStr(l[0]))
开发者ID:duoduo369,项目名称:zarkpy,代码行数:2,代码来源:site_helper.py

示例13: quote

def quote(string):
    assert(type(string) in [unicode, str])
    return _quote(string.encode('utf-8')) if isinstance(string, unicode) else _quote(string)
开发者ID:alliadt,项目名称:zarkpy,代码行数:3,代码来源:site_helper.py

示例14: quote

def quote(_i):
    return _quote(_i, "")
开发者ID:khalidhsu,项目名称:Python-K.Drive-SDK,代码行数:2,代码来源:oauth.py

示例15: quote

 def quote(string, safe=b'/'):
     if not isinstance(safe, bytes):
         safe = safe.encode('ascii', 'ignore')
     if not isinstance(string, bytes):
         string = string.encode('utf8')
     return _quote(string, safe)
开发者ID:AspenWeb,项目名称:pando.py,代码行数:6,代码来源:urlparse.py


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