お世話になります。
いまPython入門【2&3対応】という書籍で学習しております
unicode文字列への変換でエラーが頻発する原因がわかりません
お教えください
C:\Users\mtg-1>python
Python 2.7.12 |Anaconda 4.2.0 (64-bit)| (default, Jun 29 2016, 11:07:13) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
unicode('あいう') 2系ですと日本語の前にUをつければきちんと表示されます
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'utf8' codec can't decode byte 0x82 in position 0: invalid start byte
unicode('あいう', 'utf-8')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'utf8' codec can't decode byte 0x82 in position 0: invalid start byte
'あいう'.decode()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\mtg-1\Anaconda2\lib\encodings\utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0x82 in position 0: invalid start byte
unicode('あいう', 'euc_jp')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'euc_jp' codec can't decode bytes in position 0-1: illegal multibyte sequence
unicode('あいう', 'euc_jp', 'replace')
u'\ufffd\ufffd\ufffd' ここはエラーを指定しているのでOKです
はかの部分のエラーはどうして出るのかが知りたいです
ご指導ください
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/12/21 00:58
2016/12/21 01:17
2016/12/21 01:20
2016/12/21 03:43
2016/12/21 04:47
2016/12/21 04:51
2016/12/21 05:27
2016/12/22 01:36
2016/12/22 05:16
2016/12/22 05:29