Convert python filenames to unicode -
I'm on python 2.6 for Windows.
I use Oaswas to read a file tree. Files can have non-7-bit characters (for example, German "AE") in their filenames, they are encoded in Python's internal string representation.
I am processing these filenames with Python library functions and they fail due to incorrect encoding.
Do I have these files (Unicode?) Python Strings?
I have a file "d: \ utest \ ΓΌ.txt". Passing paths in the form of Unicode does not work:
& gt; & Gt; & Gt; List (o.wock ('d: \ uustest')) [('D: \\ qualification', [], ['xfc.txt'])]> gt; & Gt; & Gt; List (ow: u \\\\\\\\\) [(u'd: \\ utest ', [], [u' \ xfc.txt '])]
< / Div>
If you pass a unicode string for os.walk ()
, you can use Unicode The result will be:
& gt; & Gt; & Gt; List (OSKAAC (RC: \ example ')) Passing # ASCII string [(' C: \\ Example ', [], [' file.txt '])]> gt; & Gt; & Gt; & Gt; & Gt; & Gt; Passing a Unicode string [(U 'C: \\ Example', [], [u'file.txt '])]
Comments
Post a Comment