Hi, I'm a newbie here and kobo programming...
I installed Python 3.4 with reference to Lucas Malor's post(https://www.mobileread.com/forums/sh....php?p=2885820)
And wrote some python scripts, but met exceptions while handling non-alphabetical characters - Korean.
My simple code is below.
Result:
Alphabet-named-files are printed normally, but Non-alphabet-named-files occurred exceptions.
So, I tried to set PYTHONIOENCODING,
Result:
Ofcourse, I can use decode() or encode(), but in this case, there will be other problems like save or web-requesting non-alphabetic-named files.
What can I do to solve this problem?
I installed Python 3.4 with reference to Lucas Malor's post(https://www.mobileread.com/forums/sh....php?p=2885820)
And wrote some python scripts, but met exceptions while handling non-alphabetical characters - Korean.
My simple code is below.
Quote:
#!/usr/bin/python3 # -*- coding: utf-8 -*- import os import sys path = '/mnt/onboard/Library' for sub in os.listdir(path): print(sub)
|
Quote:
<_io.TextIOWrapper name='<stderr>' mode='w' encoding='ANSI_X3.4-1968'> <_io.TextIOWrapper name='<stdout>' mode='w' encoding='ANSI_X3.4-1968'> ... Traceback (most recent call last): File "./ta.py", line 11, in <module> UnicodeEncodeError: 'ascii' codec can't encode characters in position 16-27: ordinal not in range(128)
print(sub) |
So, I tried to set PYTHONIOENCODING,
Quote:
export PYTHONIOENCODING="UTF-8" |
Quote:
<_io.TextIOWrapper name='<stderr>' mode='w' encoding='UTF-8'> <_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'> ... Traceback (most recent call last): File "./ta.py", line 11, in <module> UnicodeEncodeError: 'utf-8' codec can't encode character '\udceb' in position 16: surrogates not allowed
print(sub) |
What can I do to solve this problem?