やっぱりエンコードはよくわからない
#!/usr/bin/env python # -*- coding: UTF-8 -*- def test(): """ >>> test() あいうえお """ a = 'あいうえお' print a a = 'あいうえお' print a.decode('utf-8') >実行結果 縺ゅ>縺・∴縺 あいうえお
#!/usr/bin/env python # -*- coding: UTF-8 -*- def test(): """ >>> test() あいうえお """ a = u'あいうえお' print a >実行結果 あいうえお
#!/usr/bin/env python # -*- coding: UTF-8 -*- def test(): """ >>> test() あいうえお """ a = u'あいうえお' print a def _test(): import doctest doctest.testmod() if __name__ == '__main__': _test() >実行結果 Traceback (most recent call last): UnicodeDecodeError: 'ascii' codec can't decode byte 0xe3 in position 14: ordinal not in range(128)
doctestはUTF-8禁止なのでしょうか。。