0

I have the following code:

#!/usr/bin/python
# -*- coding: utf-8 -*-

import os
for filename in os.listdir(u'/path/to/my/folder'):
    with open(filename) as f:
        # do something about it

And I am getting an error like this:

Traceback (most recent call last):
  File "/home/user/test/src/main.py", line 6, in <module>
    with open(filename) as f:
IOError: [Errno 2] No such file or directory: u'helloworld\u751f.html'

Any idea?

I am using python 2.7.5 if it matters.

Thanks in advance!

Hei
  • 1,844
  • 3
  • 21
  • 35
  • [This other thread could be helpful](https://stackoverflow.com/questions/5974585/python-not-able-to-open-file-with-non-english-characters-in-path) – Tomos Williams Jun 06 '17 at 15:47
  • Possible duplicate of [Python not able to open file with non-english characters in path](https://stackoverflow.com/questions/5974585/python-not-able-to-open-file-with-non-english-characters-in-path) – stovfl Jun 07 '17 at 13:55
  • Not exactly the same issue. But I managed to get around the issue without code change but an upgrade to Python 3.4. – Hei Jun 15 '17 at 03:08

0 Answers0