本文整理汇总了Python中pandas.io.formats.console.detect_console_encoding方法的典型用法代码示例。如果您正苦于以下问题:Python console.detect_console_encoding方法的具体用法?Python console.detect_console_encoding怎么用?Python console.detect_console_encoding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pandas.io.formats.console
的用法示例。
在下文中一共展示了console.detect_console_encoding方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_detect_console_encoding_from_stdout_stdin
# 需要导入模块: from pandas.io.formats import console [as 别名]
# 或者: from pandas.io.formats.console import detect_console_encoding [as 别名]
def test_detect_console_encoding_from_stdout_stdin(monkeypatch, empty, filled):
# Ensures that when sys.stdout.encoding or sys.stdin.encoding is used when
# they have values filled.
# GH 21552
with monkeypatch.context() as context:
context.setattr('sys.{}'.format(empty), MockEncoding(''))
context.setattr('sys.{}'.format(filled), MockEncoding(filled))
assert detect_console_encoding() == filled
示例2: test_detect_console_encoding_fallback_to_locale
# 需要导入模块: from pandas.io.formats import console [as 别名]
# 或者: from pandas.io.formats.console import detect_console_encoding [as 别名]
def test_detect_console_encoding_fallback_to_locale(monkeypatch, encoding):
# GH 21552
with monkeypatch.context() as context:
context.setattr('locale.getpreferredencoding', lambda: 'foo')
context.setattr('sys.stdout', MockEncoding(encoding))
assert detect_console_encoding() == 'foo'
示例3: test_detect_console_encoding_fallback_to_default
# 需要导入模块: from pandas.io.formats import console [as 别名]
# 或者: from pandas.io.formats.console import detect_console_encoding [as 别名]
def test_detect_console_encoding_fallback_to_default(monkeypatch, std, locale):
# When both the stdout/stdin encoding and locale preferred encoding checks
# fail (or return 'ascii', we should default to the sys default encoding.
# GH 21552
with monkeypatch.context() as context:
context.setattr(
'locale.getpreferredencoding',
lambda: MockEncoding.raise_or_return(locale)
)
context.setattr('sys.stdout', MockEncoding(std))
context.setattr('sys.getdefaultencoding', lambda: 'sysDefaultEncoding')
assert detect_console_encoding() == 'sysDefaultEncoding'