KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm running python 2.6 with latest IPython on Windows XP SP3, and I have two questions. First one of my problems is, when under IPython, I cannot input Unicode strings directly, and, as a result, cannot open files with non-latin names. Let me demonstrate. Under usual python this works: >>> sys.getdefaultencoding() 'ascii' >>> sys.getfilesystemencoding() 'mbcs' >>> fd = open(u'm:/Блокнот/home.tdl') >>> print u'm:/Блокнот/home.tdl' m:/Блокнот/home.tdl >>> It's cyrillic in there, by the way. And under the IPython I get: In [49]: sys.getdefaultencoding() Out[49]: 'ascii' In [50]: sys.getfilesystemencoding() Out[50]: 'mbcs' In [52]: fd = open(u'm:/Блокнот/home.tdl') --------------------------------------------------------------------------- IOError Traceback (most recent call last) C:\Documents and Settings\andrey\<ipython console> in <module>() IOError: [Errno 2] No such file or directory: u'm:/\x81\xab\xae\xaa\xad\xae\xe2/home.tdl' In [53]: print u'm:/Блокнот/home.tdl' -------------->print(u'm:/Блокнот/home.tdl') ERROR: An unexpected error occurred while tokenizing input The following traceback may be corrupted or invalid The error message is: ('EOF in multi-line statement', (15, 0)) --------------------------------------------------------------------------- UnicodeEncodeError Traceback (most recent call last) C:\Documents and Settings\andrey\<ipython console> in <module>() C:\Program Files\Python26\lib\encodings\cp866.pyc in encode(self, input, errors) 10 11 def encode(self,input,errors='strict'): ---> 12 return codecs.charmap_encode(input,errors,encoding_map) 13 14 def decode(self,input,errors='strict'): UnicodeEncodeError: 'charmap' codec can't encode characters in position 3-9: character maps to <und In [54]: The seco
Tags (comma-separated)
Save Edits
Cancel