How does python read files with special characters in the file name, such as xi? New txt
However, I went to find its explanation:
Os.listdir (path)
Return? Answer? List? Contain? That? Name? Yes? That? Entries? Are you online? That? Directory? Given? Bypass ? That? List? Is it? Are you online? Arbitrary? Order. ? It? Is it? Isn't it? Including? That? special
Entries? '.'? And then what? '..'? Even? What if? They? Is it? A gift? Are you online? this
Catalogue.
Availability:? Unix,? Windows.
Changed? Are you online? Version? 2.3:? Open? Windows? NT/2k/XP? And then what? Unix,? What if? Path? Is it? Answer? Unicode? Object? That? The result? Will. be
Answer? List? Yes? Unicode? Object. ? Undecipherable? File name? Will. Or? Is it? Did you return it? be like
String? Object. So:
You can try, the incoming path is unicode, for example:
foundDirList? =? Os.listdir(u "enter your" here) Then, the output list of file names in the list is all unicode, and you can normally display the file names you want, including special characters. Then it can be opened normally.
Of course, if the file is non-ASCII, such as Chinese, you need to understand that character encoding is involved. At this time, it is best to use the codec module. How to use, please refer to:
The tutorial uses Python's codec to process various character-coded strings and files. You can't post the address here. You can find the post through Google title search.