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


Python os.device_encoding方法代码示例

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


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

示例1: test_bad_fd

# 需要导入模块: import os [as 别名]
# 或者: from os import device_encoding [as 别名]
def test_bad_fd(self):
        # Return None when an fd doesn't actually exist.
        self.assertIsNone(os.device_encoding(123456)) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:5,代码来源:test_os.py

示例2: test_device_encoding

# 需要导入模块: import os [as 别名]
# 或者: from os import device_encoding [as 别名]
def test_device_encoding(self):
        encoding = os.device_encoding(0)
        self.assertIsNotNone(encoding)
        self.assertTrue(codecs.lookup(encoding)) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:6,代码来源:test_os.py

示例3: __init__

# 需要导入模块: import os [as 别名]
# 或者: from os import device_encoding [as 别名]
def __init__(self, buffer, encoding=None, errors=None, newline=None,
                 line_buffering=False, write_through=False):
        self._check_newline(newline)
        if encoding is None:
            try:
                encoding = os.device_encoding(buffer.fileno())
            except (AttributeError, UnsupportedOperation):
                pass
            if encoding is None:
                try:
                    import locale
                except ImportError:
                    # Importing locale may fail if Python is being built
                    encoding = "ascii"
                else:
                    encoding = locale.getpreferredencoding(False)

        if not isinstance(encoding, str):
            raise ValueError("invalid encoding: %r" % encoding)

        if not codecs.lookup(encoding)._is_text_encoding:
            msg = ("%r is not a text encoding; "
                   "use codecs.open() to handle arbitrary codecs")
            raise LookupError(msg % encoding)

        if errors is None:
            errors = "strict"
        else:
            if not isinstance(errors, str):
                raise ValueError("invalid errors: %r" % errors)

        self._buffer = buffer
        self._decoded_chars = ''  # buffer for text returned from decoder
        self._decoded_chars_used = 0  # offset into _decoded_chars for read()
        self._snapshot = None  # info for reconstructing decoder state
        self._seekable = self._telling = self.buffer.seekable()
        self._has_read1 = hasattr(self.buffer, 'read1')
        self._configure(encoding, errors, newline,
                        line_buffering, write_through) 
开发者ID:CedricGuillemet,项目名称:Imogen,代码行数:41,代码来源:_pyio.py


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