samedi 28 mars 2015

Encoding and decoding in Python 2.7.5.1 on windows cmd and pycharm get diffrent result

I use this code to deal with chinese:



# -*- coding: utf-8 -*-

strInFilNname = u'%s' % raw_input("input fileName:").decode('utf-8')

pathName = u'%s' % raw_input("input filePath:").decode('utf-8')


When I run this on PyCharm everything is ok. But when I run this on windows CMD, I get this error code:



Traceback (most recent call last):
File "E:\Sites\GetAllFile.py", line 23, in <module>
strInFilNname = u'%s' % raw_input("input filename:").decode('utf-8')
File "E:\Portable Python 2.7.5.1\App\lib\encodings\utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xd3 in position 0: invalid continuation byte


I have read this python document about Unicode HOWTO, but can't get effective solution.


I really want to know why it does so .


Aucun commentaire:

Enregistrer un commentaire