Python builtins 模块,unicode() 实例源码

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

项目:GAMADV-XTD    作者:taers232c    | 项目源码 | 文件源码
def uascii_to_str(s):
        assert isinstance(s, unicode)
        return s
项目:GAMADV-XTD    作者:taers232c    | 项目源码 | 文件源码
def uascii_to_str(s):
        assert isinstance(s, unicode)
        return s.encode("ascii")
项目:GAMADV-XTD    作者:taers232c    | 项目源码 | 文件源码
def uascii_to_str(s):
        assert isinstance(s, unicode)
        return s
项目:GAMADV-XTD    作者:taers232c    | 项目源码 | 文件源码
def uascii_to_str(s):
        assert isinstance(s, unicode)
        return s.encode("ascii")
项目:Callandtext    作者:iaora    | 项目源码 | 文件源码
def uascii_to_str(s):
        assert isinstance(s, unicode)
        return s
项目:Callandtext    作者:iaora    | 项目源码 | 文件源码
def uascii_to_str(s):
        assert isinstance(s, unicode)
        return s.encode("ascii")
项目:Sudoku-Solver    作者:ayush1997    | 项目源码 | 文件源码
def uascii_to_str(s):
        assert isinstance(s, unicode)
        return s
项目:Sudoku-Solver    作者:ayush1997    | 项目源码 | 文件源码
def uascii_to_str(s):
        assert isinstance(s, unicode)
        return s.encode("ascii")
项目:GAMADV-X    作者:taers232c    | 项目源码 | 文件源码
def uascii_to_str(s):
        assert isinstance(s, unicode)
        return s
项目:GAMADV-X    作者:taers232c    | 项目源码 | 文件源码
def uascii_to_str(s):
        assert isinstance(s, unicode)
        return s.encode("ascii")
项目:GAMADV-X    作者:taers232c    | 项目源码 | 文件源码
def uascii_to_str(s):
        assert isinstance(s, unicode)
        return s
项目:GAMADV-X    作者:taers232c    | 项目源码 | 文件源码
def uascii_to_str(s):
        assert isinstance(s, unicode)
        return s.encode("ascii")
项目:enkiWS    作者:juliettef    | 项目源码 | 文件源码
def uascii_to_str(s):
        assert isinstance(s, unicode)
        return s
项目:enkiWS    作者:juliettef    | 项目源码 | 文件源码
def uascii_to_str(s):
        assert isinstance(s, unicode)
        return s.encode("ascii")
项目:python-flask-security    作者:weinbergdavid    | 项目源码 | 文件源码
def uascii_to_str(s):
        assert isinstance(s, unicode)
        return s
项目:python-flask-security    作者:weinbergdavid    | 项目源码 | 文件源码
def uascii_to_str(s):
        assert isinstance(s, unicode)
        return s.encode("ascii")
项目:GAMADV-XTD    作者:taers232c    | 项目源码 | 文件源码
def print_(*args, **kwds):
        """The new-style print function."""
        # extract kwd args
        fp = kwds.pop("file", sys.stdout)
        sep = kwds.pop("sep", None)
        end = kwds.pop("end", None)
        if kwds:
            raise TypeError("invalid keyword arguments")

        # short-circuit if no target
        if fp is None:
            return

        # use unicode or bytes ?
        want_unicode = isinstance(sep, unicode) or isinstance(end, unicode) or \
                       any(isinstance(arg, unicode) for arg in args)

        # pick default end sequence
        if end is None:
            end = u("\n") if want_unicode else "\n"
        elif not isinstance(end, base_string_types):
            raise TypeError("end must be None or a string")

        # pick default separator
        if sep is None:
            sep = u(" ") if want_unicode else " "
        elif not isinstance(sep, base_string_types):
            raise TypeError("sep must be None or a string")

        # write to buffer
        first = True
        write = fp.write
        for arg in args:
            if first:
                first = False
            else:
                write(sep)
            if not isinstance(arg, basestring):
                arg = str(arg)
            write(arg)
        write(end)

#=============================================================================
# lazy overlay module
#=============================================================================
项目:Callandtext    作者:iaora    | 项目源码 | 文件源码
def print_(*args, **kwds):
        """The new-style print function."""
        # extract kwd args
        fp = kwds.pop("file", sys.stdout)
        sep = kwds.pop("sep", None)
        end = kwds.pop("end", None)
        if kwds:
            raise TypeError("invalid keyword arguments")

        # short-circuit if no target
        if fp is None:
            return

        # use unicode or bytes ?
        want_unicode = isinstance(sep, unicode) or isinstance(end, unicode) or \
                       any(isinstance(arg, unicode) for arg in args)

        # pick default end sequence
        if end is None:
            end = u("\n") if want_unicode else "\n"
        elif not isinstance(end, base_string_types):
            raise TypeError("end must be None or a string")

        # pick default separator
        if sep is None:
            sep = u(" ") if want_unicode else " "
        elif not isinstance(sep, base_string_types):
            raise TypeError("sep must be None or a string")

        # write to buffer
        first = True
        write = fp.write
        for arg in args:
            if first:
                first = False
            else:
                write(sep)
            if not isinstance(arg, basestring):
                arg = str(arg)
            write(arg)
        write(end)

#=============================================================================
# lazy overlay module
#=============================================================================
项目:Sudoku-Solver    作者:ayush1997    | 项目源码 | 文件源码
def print_(*args, **kwds):
        """The new-style print function."""
        # extract kwd args
        fp = kwds.pop("file", sys.stdout)
        sep = kwds.pop("sep", None)
        end = kwds.pop("end", None)
        if kwds:
            raise TypeError("invalid keyword arguments")

        # short-circuit if no target
        if fp is None:
            return

        # use unicode or bytes ?
        want_unicode = isinstance(sep, unicode) or isinstance(end, unicode) or \
                       any(isinstance(arg, unicode) for arg in args)

        # pick default end sequence
        if end is None:
            end = u("\n") if want_unicode else "\n"
        elif not isinstance(end, base_string_types):
            raise TypeError("end must be None or a string")

        # pick default separator
        if sep is None:
            sep = u(" ") if want_unicode else " "
        elif not isinstance(sep, base_string_types):
            raise TypeError("sep must be None or a string")

        # write to buffer
        first = True
        write = fp.write
        for arg in args:
            if first:
                first = False
            else:
                write(sep)
            if not isinstance(arg, basestring):
                arg = str(arg)
            write(arg)
        write(end)

#=============================================================================
# lazy overlay module
#=============================================================================
项目:GAMADV-X    作者:taers232c    | 项目源码 | 文件源码
def print_(*args, **kwds):
        """The new-style print function."""
        # extract kwd args
        fp = kwds.pop("file", sys.stdout)
        sep = kwds.pop("sep", None)
        end = kwds.pop("end", None)
        if kwds:
            raise TypeError("invalid keyword arguments")

        # short-circuit if no target
        if fp is None:
            return

        # use unicode or bytes ?
        want_unicode = isinstance(sep, unicode) or isinstance(end, unicode) or \
                       any(isinstance(arg, unicode) for arg in args)

        # pick default end sequence
        if end is None:
            end = u("\n") if want_unicode else "\n"
        elif not isinstance(end, base_string_types):
            raise TypeError("end must be None or a string")

        # pick default separator
        if sep is None:
            sep = u(" ") if want_unicode else " "
        elif not isinstance(sep, base_string_types):
            raise TypeError("sep must be None or a string")

        # write to buffer
        first = True
        write = fp.write
        for arg in args:
            if first:
                first = False
            else:
                write(sep)
            if not isinstance(arg, basestring):
                arg = str(arg)
            write(arg)
        write(end)

#=============================================================================
# lazy overlay module
#=============================================================================
项目:enkiWS    作者:juliettef    | 项目源码 | 文件源码
def print_(*args, **kwds):
        """The new-style print function."""
        # extract kwd args
        fp = kwds.pop("file", sys.stdout)
        sep = kwds.pop("sep", None)
        end = kwds.pop("end", None)
        if kwds:
            raise TypeError("invalid keyword arguments")

        # short-circuit if no target
        if fp is None:
            return

        # use unicode or bytes ?
        want_unicode = isinstance(sep, unicode) or isinstance(end, unicode) or \
                       any(isinstance(arg, unicode) for arg in args)

        # pick default end sequence
        if end is None:
            end = u("\n") if want_unicode else "\n"
        elif not isinstance(end, base_string_types):
            raise TypeError("end must be None or a string")

        # pick default separator
        if sep is None:
            sep = u(" ") if want_unicode else " "
        elif not isinstance(sep, base_string_types):
            raise TypeError("sep must be None or a string")

        # write to buffer
        first = True
        write = fp.write
        for arg in args:
            if first:
                first = False
            else:
                write(sep)
            if not isinstance(arg, basestring):
                arg = str(arg)
            write(arg)
        write(end)

#=============================================================================
# lazy overlay module
#=============================================================================
项目:python-flask-security    作者:weinbergdavid    | 项目源码 | 文件源码
def print_(*args, **kwds):
        """The new-style print function."""
        # extract kwd args
        fp = kwds.pop("file", sys.stdout)
        sep = kwds.pop("sep", None)
        end = kwds.pop("end", None)
        if kwds:
            raise TypeError("invalid keyword arguments")

        # short-circuit if no target
        if fp is None:
            return

        # use unicode or bytes ?
        want_unicode = isinstance(sep, unicode) or isinstance(end, unicode) or \
                       any(isinstance(arg, unicode) for arg in args)

        # pick default end sequence
        if end is None:
            end = u("\n") if want_unicode else "\n"
        elif not isinstance(end, base_string_types):
            raise TypeError("end must be None or a string")

        # pick default separator
        if sep is None:
            sep = u(" ") if want_unicode else " "
        elif not isinstance(sep, base_string_types):
            raise TypeError("sep must be None or a string")

        # write to buffer
        first = True
        write = fp.write
        for arg in args:
            if first:
                first = False
            else:
                write(sep)
            if not isinstance(arg, basestring):
                arg = str(arg)
            write(arg)
        write(end)

#=============================================================================
# lazy overlay module
#=============================================================================