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


Python __builtin__.unicode方法代码示例

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


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

示例1: _decode_line

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import unicode [as 别名]
def _decode_line(line, encoding=None):
    """Decode bytes from binary input streams.

    Defaults to decoding from 'latin1'. That differs from the behavior of
    np.compat.asunicode that decodes from 'ascii'.

    Parameters
    ----------
    line : str or bytes
         Line to be decoded.

    Returns
    -------
    decoded_line : unicode
         Unicode in Python 2, a str (unicode) in Python 3.

    """
    if type(line) is bytes:
        if encoding is None:
            line = line.decode('latin1')
        else:
            line = line.decode(encoding)

    return line 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:26,代码来源:_iotools.py

示例2: __init__

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import unicode [as 别名]
def __init__(self, delimiter=None, comments=asbytes('#'), autostrip=True):
        self.comments = comments
        # Delimiter is a character
        if isinstance(delimiter, unicode):
            delimiter = delimiter.encode('ascii')
        if (delimiter is None) or _is_bytes_like(delimiter):
            delimiter = delimiter or None
            _handyman = self._delimited_splitter
        # Delimiter is a list of field widths
        elif hasattr(delimiter, '__iter__'):
            _handyman = self._variablewidth_splitter
            idx = np.cumsum([0] + list(delimiter))
            delimiter = [slice(i, j) for (i, j) in zip(idx[:-1], idx[1:])]
        # Delimiter is a single integer
        elif int(delimiter):
            (_handyman, delimiter) = (
                    self._fixedwidth_splitter, int(delimiter))
        else:
            (_handyman, delimiter) = (self._delimited_splitter, None)
        self.delimiter = delimiter
        if autostrip:
            self._handyman = self.autostrip(_handyman)
        else:
            self._handyman = _handyman
    # 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:27,代码来源:_iotools.py

示例3: __init__

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import unicode [as 别名]
def __init__(self, delimiter=None, comments=asbytes('#'), autostrip=True):
        self.comments = comments
        # Delimiter is a character
        if isinstance(delimiter, unicode):
            delimiter = delimiter.encode('ascii')
        if (delimiter is None) or _is_bytes_like(delimiter):
            delimiter = delimiter or None
            _handyman = self._delimited_splitter
        # Delimiter is a list of field widths
        elif hasattr(delimiter, '__iter__'):
            _handyman = self._variablewidth_splitter
            idx = np.cumsum([0] + list(delimiter))
            delimiter = [slice(i, j) for (i, j) in zip(idx[:-1], idx[1:])]
        # Delimiter is a single integer
        elif int(delimiter):
            (_handyman, delimiter) = (self._fixedwidth_splitter, int(delimiter))
        else:
            (_handyman, delimiter) = (self._delimited_splitter, None)
        self.delimiter = delimiter
        if autostrip:
            self._handyman = self.autostrip(_handyman)
        else:
            self._handyman = _handyman
    # 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:26,代码来源:_iotools.py

示例4: __init__

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import unicode [as 别名]
def __init__(self, delimiter=None, comments=b'#', autostrip=True):
        self.comments = comments
        # Delimiter is a character
        if isinstance(delimiter, unicode):
            delimiter = delimiter.encode('ascii')
        if (delimiter is None) or _is_bytes_like(delimiter):
            delimiter = delimiter or None
            _handyman = self._delimited_splitter
        # Delimiter is a list of field widths
        elif hasattr(delimiter, '__iter__'):
            _handyman = self._variablewidth_splitter
            idx = np.cumsum([0] + list(delimiter))
            delimiter = [slice(i, j) for (i, j) in zip(idx[:-1], idx[1:])]
        # Delimiter is a single integer
        elif int(delimiter):
            (_handyman, delimiter) = (
                    self._fixedwidth_splitter, int(delimiter))
        else:
            (_handyman, delimiter) = (self._delimited_splitter, None)
        self.delimiter = delimiter
        if autostrip:
            self._handyman = self.autostrip(_handyman)
        else:
            self._handyman = _handyman
    # 
开发者ID:awslabs,项目名称:mxnet-lambda,代码行数:27,代码来源:_iotools.py

示例5: test_retrieves_version_of_self

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import unicode [as 别名]
def test_retrieves_version_of_self(self):
        pkg_version = version('egginfo-pkg')
        assert isinstance(pkg_version, text)
        assert re.match(self.version_pattern, pkg_version) 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:6,代码来源:test_api.py

示例6: test_retrieves_version_of_distinfo_pkg

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import unicode [as 别名]
def test_retrieves_version_of_distinfo_pkg(self):
        pkg_version = version('distinfo-pkg')
        assert isinstance(pkg_version, text)
        assert re.match(self.version_pattern, pkg_version) 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:6,代码来源:test_api.py

示例7: test_retrieves_version_of_self

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import unicode [as 别名]
def test_retrieves_version_of_self(self):
        dist = Distribution.from_name('distinfo-pkg')
        assert isinstance(dist.version, text)
        assert re.match(self.version_pattern, dist.version) 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:6,代码来源:test_main.py

示例8: _str

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import unicode [as 别名]
def _str(s, encoding="UTF-8"):
        return unicode(s, encoding=encoding) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:4,代码来源:common_imports.py

示例9: unicode

# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import unicode [as 别名]
def unicode(s):  # pylint: disable=invalid-name
    """Force conversion of s to unicode."""
    return __builtin__.unicode(s, 'utf-8')


# In Python 3.2+, readfp is deprecated in favor of read_file, which doesn't
# exist in Python 2 yet. To avoid deprecation warnings, subclass ConfigParser to
# fix this - now read_file works across all Python versions we care about. 
开发者ID:google,项目名称:yapf,代码行数:10,代码来源:py3compat.py


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