unicode and os.listdir

"Martin v. Löwis" martin at v.loewis.de
Sat Mar 15 13:17:26 EST 2003


Sten Dahlgren wrote:
> Problem: i would like to scan through a windows volume that contains 
> filenames with unicode filenames (utf16) but when i try os.listdir("y:")
> i get the result ['???'] the only file there is 3 unicode characters wide

I assume you are using some variant of Microsoft Windows?

In that case, you should use Python 2.3, and pass a Unicode directory
name to listdir; the resulting file names will then be Unicode objects
as well (see PEP 277).

Regards,
Martin





More information about the Python-list mailing list