User Tools

Site Tools


doc:appunti:prog:python_unicode

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
doc:appunti:prog:python_unicode [2013/01/28 10:05] – [Nomi di file e directory] niccolodoc:appunti:prog:python_unicode [2013/01/28 13:09] – [Nomi di file e directory] niccolo
Line 77: Line 77:
 <code python> <code python>
 os.path.isfile(filename) os.path.isfile(filename)
 +os.stat(filename)
 </code> </code>
  
Line 84: Line 85:
 UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 79: ordinal not in range(128) UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 79: ordinal not in range(128)
 </code> </code>
 +
 +La soluzione è codificare esplicitamente la stringa prima di passarla alla funzione:
 +
 +<code python>
 +os.path.isfile(filename.encode('utf-8'))
 +os.stat(filename.encode('utf-8'))
 +</code>
 +
doc/appunti/prog/python_unicode.txt · Last modified: 2015/07/17 09:50 by niccolo