unicode and os.listdir

Sten Dahlgren stda at enea.se
Sun Mar 16 06:32:49 EST 2003


Martin v. Löwis wrote:

> 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?
> 


yepp



> 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).


got it, i used os.listdir(unicode("y:"))


thanks for taking your time it saved me!


> 
> Regards,
> Martin
> 





More information about the Python-list mailing list