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


Python builtins.chr方法代码示例

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


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

示例1: test_unquoting

# 需要导入模块: from future import builtins [as 别名]
# 或者: from future.builtins import chr [as 别名]
def test_unquoting(self):
        # Make sure unquoting of all ASCII values works
        escape_list = []
        for num in range(128):
            given = hexescape(chr(num))
            expect = chr(num)
            result = urllib_parse.unquote(given)
            self.assertEqual(expect, result,
                             "using unquote(): %r != %r" % (expect, result))
            result = urllib_parse.unquote_plus(given)
            self.assertEqual(expect, result,
                             "using unquote_plus(): %r != %r" %
                             (expect, result))
            escape_list.append(given)
        escape_string = ''.join(escape_list)
        del escape_list
        result = urllib_parse.unquote(escape_string)
        self.assertEqual(result.count('%'), 1,
                         "using unquote(): not all characters escaped: "
                         "%s" % result)
        self.assertRaises((TypeError, AttributeError), urllib_parse.unquote, None)
        self.assertRaises((TypeError, AttributeError), urllib_parse.unquote, ())
        with support.check_warnings(('', BytesWarning), quiet=True):
            self.assertRaises((TypeError, AttributeError), urllib_parse.unquote, bytes(b'')) 
开发者ID:hughperkins,项目名称:kgsgo-dataset-preprocessor,代码行数:26,代码来源:test_urllib.py

示例2: truelen

# 需要导入模块: from future import builtins [as 别名]
# 或者: from future.builtins import chr [as 别名]
def truelen(string):
    """
    It appears one Asian character takes two spots, but __len__
    counts it as three, so this function counts the dispalyed
    length of the string.

    >>> truelen('abc')
    3
    >>> truelen('你好')
    4
    >>> truelen('1二3')
    4
    >>> truelen('')
    0
    """
    return len(string) + sum(1 for c in string if c > chr(127)) 
开发者ID:darknessomi,项目名称:musicbox,代码行数:18,代码来源:scrollstring.py

示例3: _populate_class_variables

# 需要导入模块: from future import builtins [as 别名]
# 或者: from future.builtins import chr [as 别名]
def _populate_class_variables():
        lookup = {}
        reverse_lookup = {}
        characters_for_re = []

        # &apos is an XHTML entity and an HTML 5, but not an HTML 4
        # entity. We don't want to use it, but we want to recognize it on the way in.
        #
        # TODO: Ideally we would be able to recognize all HTML 5 named
        # entities, but that's a little tricky.
        extra = [(39, 'apos')]
        for codepoint, name in list(codepoint2name.items()) + extra:
            character = chr(codepoint)
            if codepoint not in (34, 39):
                # There's no point in turning the quotation mark into
                # " or the single quote into ', unless it
                # happens within an attribute value, which is handled
                # elsewhere.
                characters_for_re.append(character)
                lookup[character] = name
            # But we do want to recognize those entities on the way in and
            # convert them to Unicode characters.
            reverse_lookup[name] = character
        re_definition = "[%s]" % "".join(characters_for_re)
        return lookup, reverse_lookup, re.compile(re_definition) 
开发者ID:Tautulli,项目名称:Tautulli,代码行数:27,代码来源:dammit.py

示例4: header_check

# 需要导入模块: from future import builtins [as 别名]
# 或者: from future.builtins import chr [as 别名]
def header_check(octet):
    """Return True if the octet should be escaped with header quopri."""
    return chr(octet) != _QUOPRI_HEADER_MAP[octet] 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:5,代码来源:quoprimime.py

示例5: body_check

# 需要导入模块: from future import builtins [as 别名]
# 或者: from future.builtins import chr [as 别名]
def body_check(octet):
    """Return True if the octet should be escaped with body quopri."""
    return chr(octet) != _QUOPRI_BODY_MAP[octet] 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:5,代码来源:quoprimime.py

示例6: _max_append

# 需要导入模块: from future import builtins [as 别名]
# 或者: from future.builtins import chr [as 别名]
def _max_append(L, s, maxlen, extra=''):
    if not isinstance(s, str):
        s = chr(s)
    if not L:
        L.append(s.lstrip())
    elif len(L[-1]) + len(s) <= maxlen:
        L[-1] += extra + s
    else:
        L.append(s.lstrip()) 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:11,代码来源:quoprimime.py

示例7: unquote

# 需要导入模块: from future import builtins [as 别名]
# 或者: from future.builtins import chr [as 别名]
def unquote(s):
    """Turn a string in the form =AB to the ASCII character with value 0xab"""
    return chr(int(s[1:3], 16)) 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:5,代码来源:quoprimime.py

示例8: __missing__

# 需要导入模块: from future import builtins [as 别名]
# 或者: from future.builtins import chr [as 别名]
def __missing__(self, key):
        if key in self.safe:
            self[key] = chr(key)
        else:
            self[key] = "={:02X}".format(key)
        return self[key] 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:8,代码来源:_encoded_words.py

示例9: __missing__

# 需要导入模块: from future import builtins [as 别名]
# 或者: from future.builtins import chr [as 别名]
def __missing__(self, b):
        # Handle a cache miss. Store quoted string in cache and return.
        res = chr(b) if b in self.safe else '%{0:02X}'.format(b)
        self[b] = res
        return res 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:7,代码来源:parse.py


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