How to open a file with chinese name in python.
- by mahendraliya
I am trying to open a file in "w" mode with "open()" function in python.
The filename is : ?????.jpg.
The open function fails with this filename but succeeds with normal files.
How can I open a file with names which are not in English in python?
My code is as follows:
try:
filename = urllib.quote(filename.encode('utf-8'))
destination = open(filename, 'w')
yield("<br>Obtained the file reference")
except:
yield("<br>Error while opening the file")
I always get "Error while opening the file" for non-english filenames.
Thanks in advance.