Python __builtin__ 模块,ord() 实例源码

我们从Python开源项目中,提取了以下17个代码示例,用于说明如何使用__builtin__.ord()

项目:respeaker_virtualenv    作者:respeaker    | 项目源码 | 文件源码
def get_mac_address(ifname):
    import fcntl
    ifname = ifname[:15]
    if PY3:
        ifname = bytes(ifname, 'ascii')
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    with contextlib.closing(s):
        info = fcntl.ioctl(
            s.fileno(), SIOCGIFHWADDR, struct.pack('256s', ifname))
        if PY3:
            def ord(x):
                return x
        else:
            import __builtin__
            ord = __builtin__.ord
        return ''.join(['%02x:' % ord(char) for char in info[18:24]])[:-1]
项目:zenchmarks    作者:squeaky-pl    | 项目源码 | 文件源码
def get_mac_address(ifname):
    import fcntl
    ifname = ifname[:15]
    if PY3:
        ifname = bytes(ifname, 'ascii')
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    with contextlib.closing(s):
        info = fcntl.ioctl(
            s.fileno(), SIOCGIFHWADDR, struct.pack('256s', ifname))
        if PY3:
            def ord(x):
                return x
        else:
            import __builtin__
            ord = __builtin__.ord
        return ''.join(['%02x:' % ord(char) for char in info[18:24]])[:-1]
项目:FancyWord    作者:EastonLee    | 项目源码 | 文件源码
def get_mac_address(ifname):
    import fcntl
    ifname = ifname[:15]
    if PY3:
        ifname = bytes(ifname, 'ascii')
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    with contextlib.closing(s):
        info = fcntl.ioctl(
            s.fileno(), SIOCGIFHWADDR, struct.pack('256s', ifname))
        if PY3:
            def ord(x):
                return x
        else:
            import __builtin__
            ord = __builtin__.ord
        return ''.join(['%02x:' % ord(char) for char in info[18:24]])[:-1]
项目:FMoviesPlus.bundle    作者:coder-alpha    | 项目源码 | 文件源码
def a01(t, token_error=False, is9Anime=False):
    i = 0
    for e in range(0, len(t)):
        if token_error == False:
            if is9Anime == False:
                i += ord(t[e]) + e
            else:
                i += ord(t[e]) * e
        else:
            try:
                i += eval('ord(t[%s]) %s' % (e, TOKEN_OPER[0]))
            except:
                i += eval('ord(t[%s]) %s' % (e, TOKEN_OPER[1]))
    return i

#6856
项目:true_review_web2py    作者:lucadealfaro    | 项目源码 | 文件源码
def ord(char):
    """Returns unicode id for utf8 or unicode *char* character
    SUPPOSE that *char* is an utf-8 or unicode character only
    """
    if isinstance(char, unicode):
        return __builtin__.ord(char)
    return __builtin__.ord(unicode(char, 'utf-8'))
项目:spc    作者:whbrewer    | 项目源码 | 文件源码
def ord(char):
    """ returns unicode id for utf8 or unicode *char* character

        SUPPOSE that *char* is an utf-8 or unicode character only
    """
    if isinstance(char, unicode):
        return __builtin__.ord(char)
    return __builtin__.ord(unicode(char, 'utf-8'))
项目:Problematica-public    作者:TechMaz    | 项目源码 | 文件源码
def ord(char):
    """Returns unicode id for utf8 or unicode *char* character
    SUPPOSE that *char* is an utf-8 or unicode character only
    """
    if isinstance(char, unicode):
        return __builtin__.ord(char)
    return __builtin__.ord(unicode(char, 'utf-8'))
项目:web3py    作者:web2py    | 项目源码 | 文件源码
def ord(char):
    """Returns unicode id for utf8 or unicode *char* character
    SUPPOSE that *char* is an utf-8 or unicode character only
    """
    if isinstance(char, unicode):
        return __builtin__.ord(char)
    return __builtin__.ord(unicode(char, 'utf-8'))
项目:slugiot-client    作者:slugiot    | 项目源码 | 文件源码
def ord(char):
    """Returns unicode id for utf8 or unicode *char* character
    SUPPOSE that *char* is an utf-8 or unicode character only
    """
    if isinstance(char, unicode):
        return __builtin__.ord(char)
    return __builtin__.ord(unicode(char, 'utf-8'))
项目:FMoviesPlus.bundle    作者:coder-alpha    | 项目源码 | 文件源码
def r01(t, e, token_error=False):
    i = 0
    n = 0
    for i in range(0, max(len(t), len(e))):
        if i < len(e):
            n += ord(e[i])
        if i < len(t):
            n += ord(t[i])
    h = format(int(hex(n),16),'x')
    return h
项目:FMoviesPlus.bundle    作者:coder-alpha    | 项目源码 | 文件源码
def decode_t(t, i, is9Anime=False, **kwargs):
    n = [] 
    e = []
    r = ''

    if common.ENCRYPTED_URLS == False:
        return True, t

    try:
        if is9Anime == True:
            return decode_t2(t)
        for n in range(0, len(t)):
            if n==0 and t[n] == '.':
                pass
            else:
                c = ord(t[n])
                if c >= 97 and c <= 122:
                    e.append((c - 71 + i) % 26 + 97)
                elif c >= 65 and c <= 90:
                    e.append((c - 39 + i) % 26 + 65)
                else:
                    e.append(c)
        for ee in e:
            r += chr(ee)

        return True, r
    except Exception as e:
        Log("fmovies.py > decode_t > %s" % e)
    return False, 'Error in decoding val'
项目:FMoviesPlus.bundle    作者:coder-alpha    | 项目源码 | 文件源码
def cleanJSS1(str):
    if str == None: raise ValueError("cleanJSS: Token is None type")

    txt = str

    for i in range(0,len(str)):
        c = str[i]
        if (ord(c) <= 127 and c != '_'):
            pass
        else:
            txt = txt.replace(c, makeid(1))

    return txt
项目:FMoviesPlus.bundle    作者:coder-alpha    | 项目源码 | 文件源码
def r01(self, t, e, token_error=False):
        i = 0
        n = 0
        for i in range(0, max(len(t), len(e))):
            if i < len(e):
                n += ord(e[i])
            if i < len(t):
                n += ord(t[i])
        h = format(int(hex(n),16),'x')
        return h
项目:FMoviesPlus.bundle    作者:coder-alpha    | 项目源码 | 文件源码
def r01(self, t, e, token_error=False):
        i = 0
        n = 0
        for i in range(0, max(len(t), len(e))):
            if i < len(e):
                n += ord(e[i])
            if i < len(t):
                n += ord(t[i])
        h = format(int(hex(n),16),'x')
        return h
项目:FMoviesPlus.bundle    作者:coder-alpha    | 项目源码 | 文件源码
def a01(self, t, token_error=False):
        i = 0
        for e in range(0, len(t)):
            if token_error == False:
                i += ord(t[e]) + e
            else:
                i += ord(t[e]) * e + e
        return i
项目:FMoviesPlus.bundle    作者:coder-alpha    | 项目源码 | 文件源码
def decode_t(self, t, i):
        n = [] 
        e = []
        r = ''

        if ENCRYPTED_URLS == False:
            return True, t

        try:
            for n in range(0, len(t)):
                if n == 0 and t[n] == '.':
                    pass
                else:
                    c = ord(t[n])
                    if c >= 97 and c <= 122:
                        e.append((c - 71 + i) % 26 + 97)
                    elif c >= 65 and c <= 90:
                        e.append((c - 39 + i) % 26 + 65)
                    else:
                        e.append(c)
            for ee in e:
                r += chr(ee)

            return True, r
        except Exception as e:
            log('ERROR', 'decode_t','%s' % e, dolog=False)
            False, 'Error in decoding'
项目:StuffShare    作者:StuffShare    | 项目源码 | 文件源码
def ord(char):
    """Returns unicode id for utf8 or unicode *char* character
    SUPPOSE that *char* is an utf-8 or unicode character only
    """
    if isinstance(char, unicode):
        return __builtin__.ord(char)
    return __builtin__.ord(unicode(char, 'utf-8'))