python类unichr()的实例源码

package_index.py 文件源码 项目:python-group-proj 作者: Sharcee 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def uchr(c):
    if not isinstance(c, int):
        return c
    if c > 255:
        return six.unichr(c)
    return chr(c)
test_tokenizer.py 文件源码 项目:tefla 作者: openAGI 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test_invertibility_on_random_strings(self):
        for _ in xrange(1000):
            s = u"".join(six.unichr(random.randint(0, 65535))
                         for _ in xrange(10))
            self.assertEqual(s, self.tokenizer.decode(self.tokenizer.encode(s)))
package_index.py 文件源码 项目:PornGuys 作者: followloda 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def uchr(c):
    if not isinstance(c, int):
        return c
    if c > 255:
        return six.unichr(c)
    return chr(c)
__init__.py 文件源码 项目:geoextract 作者: stadt-karlsruhe 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def split(self, text):
        a = _string_to_array(text)
        if not a.size:
            return []
        b = np.copy(a)
        b[b == ord(' ')] = 0
        if self.margin != (1, 1):
            # Dilate the image
            structure = np.zeros((2 * (self.margin[1] - 1) + 1,
                                  2 * (self.margin[0] - 1) + 1))
            structure[self.margin[1] - 1:, self.margin[0] - 1:] = 1
            labels = binary_dilation(b, structure=structure).astype(b.dtype)
        else:
            labels = b
        num = label(labels, structure=np.ones((3, 3)), output=labels)
        objects = find_objects(labels)
        parts = []
        for i, obj in enumerate(objects):
            mask = labels[obj] != i + 1
            region = np.copy(a[obj])
            region[mask] = ord(' ')
            part = '\n'.join(''.join(unichr(c or ord(' ')) for c in row)
                             for row in region.tolist())
            if part.strip():
                parts.append(part)
        return parts
utils.py 文件源码 项目:nonce2vec 作者: minimalparts 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def safe_unichr(intval):
    try:
        return unichr(intval)
    except ValueError:
        # ValueError: unichr() arg not in range(0x10000) (narrow Python build)
        s = "\\U%08x" % intval
        # return UTF16 surrogate pair
        return s.decode('unicode-escape')
test_six.py 文件源码 项目:obsoleted-vpduserv 作者: InfraSIM 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def test_unichr():
    assert six.u("\u1234") == six.unichr(0x1234)
    assert type(six.u("\u1234")) is type(six.unichr(0x1234))
base65536.py 文件源码 项目:GCTF-challenges 作者: PlatyPew 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def encode(value):
    """Encodes bytes to a base65536 string."""
    stream = io.StringIO()
    length = len(value)
    for x in range(0, length, 2):
        b1 = indexbytes(value, x)
        b2 = indexbytes(value, x + 1) if x + 1 < length else -1
        code_point = BLOCK_START[b2] + b1
        stream.write(unichr(code_point))
    return stream.getvalue()
package_index.py 文件源码 项目:Repobot 作者: Desgard 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def uchr(c):
    if not isinstance(c, int):
        return c
    if c > 255:
        return six.unichr(c)
    return chr(c)
package_index.py 文件源码 项目:CloudPrint 作者: William-An 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def uchr(c):
    if not isinstance(c, int):
        return c
    if c > 255:
        return six.unichr(c)
    return chr(c)
test_exception.py 文件源码 项目:mogan 作者: openstack 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def test____init__(self):
        expected = b'\xc3\xa9\xe0\xaf\xb2\xe0\xbe\x84'
        if six.PY3:
            expected = expected.decode('utf-8')
        message = six.unichr(233) + six.unichr(0x0bf2) + six.unichr(3972)
        exc = exception.MoganException(message)
        self.assertEqual(expected, exc.__str__())
package_index.py 文件源码 项目:QualquerMerdaAPI 作者: tiagovizoto 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def uchr(c):
    if not isinstance(c, int):
        return c
    if c > 255:
        return six.unichr(c)
    return chr(c)
package_index.py 文件源码 项目:gardenbot 作者: GoestaO 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def uchr(c):
    if not isinstance(c, int):
        return c
    if c > 255:
        return six.unichr(c)
    return chr(c)
test_json_resource.py 文件源码 项目:aspen.py 作者: AspenWeb 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def test_json_handles_unicode(harness):
    expected = b'''{
    "Greetings": "\u00b5"
}'''
    actual = harness.simple('''
        from six import unichr
        [---]
        [---] application/json
        {'Greetings': unichr(181)}
    ''', filepath="foo.json.spt").body
    assert actual == expected
package_index.py 文件源码 项目:flask-zhenai-mongo-echarts 作者: Fretice 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def uchr(c):
    if not isinstance(c, int):
        return c
    if c > 255:
        return six.unichr(c)
    return chr(c)
package_index.py 文件源码 项目:hate-to-hugs 作者: sdoran35 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def uchr(c):
    if not isinstance(c, int):
        return c
    if c > 255:
        return six.unichr(c)
    return chr(c)
test_six.py 文件源码 项目:Deploy_XXNET_Server 作者: jzp820927 项目源码 文件源码 阅读 35 收藏 0 点赞 0 评论 0
def test_unichr():
    assert six.u("\u1234") == six.unichr(0x1234)
    assert type(six.u("\u1234")) is type(six.unichr(0x1234))
package_index.py 文件源码 项目:minihydra 作者: VillanCh 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def uchr(c):
    if not isinstance(c, int):
        return c
    if c > 255:
        return six.unichr(c)
    return chr(c)
jamo.py 文件源码 项目:hangul-utils 作者: kaniblu 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def __c(x):
    return six.unichr(x)
parameter_types.py 文件源码 项目:masakari 作者: openstack 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def _get_all_chars():
    for i in range(0xFFFF):
        yield six.unichr(i)


# build a regex that matches all printable characters. This allows
# spaces in the middle of the name. Also note that the regexp below
# deliberately allows the empty string. This is so only the constraint
# which enforces a minimum length for the name is triggered when an
# empty string is tested. Otherwise it is not deterministic which
# constraint fails and this causes issues for some unittests when
# PYTHONHASHSEED is set randomly.


问题


面经


文章

微信
公众号

扫码关注公众号