New submission from rushant <953779...@qq.com>: # -*- coding: utf-8 -*- import os job_name = os.environ['a'] print(job_name) print(isinstance(job_name, str)) print(type(job_name)) with open('name.txt', 'w', encoding='utf-8')as fw: fw.write(job_name)
i have set environment param by : export a="中文" it returns error: 中文 True <class 'str'> Traceback (most recent call last): File "aa.py", line 8, in <module> fw.write(job_name) UnicodeEncodeError: 'utf-8' codec can't encode characters in position 0-5: surrogates not allowed ---------- components: C API messages: 389215 nosy: rushant priority: normal severity: normal status: open title: python3.6.4 os.environ error when write chinese to file type: behavior versions: Python 3.6 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue43576> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com