我的工作(法國)的PC上使用Python 3.4Python的os.popen和Unicode
for line in os.popen('dir'): print(line.rstrip())
我得到的第一行預期
Le volume dans le lecteur C s'appelle SYSTEME
但第二(與)
Lenumérode s rie du volume est C 250-47DD
我得到的錯誤信息:
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u201a' in position 7: character maps to
<undefined>
我能做些什麼? 在此先感謝您的幫助
你應該使用子*,因爲不推薦使用2.6版本:此功能是過時*,或只使用OS .listdir。 – 2014-11-21 18:11:11