Message389215
# -*- 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 |
|
Date |
User |
Action |
Args |
2021-03-21 04:46:52 | rushant | set | recipients:
+ rushant |
2021-03-21 04:46:52 | rushant | set | messageid: <1616302012.93.0.356074990603.issue43576@roundup.psfhosted.org> |
2021-03-21 04:46:52 | rushant | link | issue43576 messages |
2021-03-21 04:46:52 | rushant | create | |
|