提问人:Data Analyst 提问时间:3/15/2023 最后编辑:James ZData Analyst 更新时间:3/16/2023 访问量:165
UnicodeEncodeError:“charmap”编解码器无法对位置 409 中的字符“\u03a3”进行编码:字符映射到 <undefined>
UnicodeEncodeError: 'charmap' codec can't encode character '\u03a3' in position 409: character maps to <undefined>
问:
我正在运行 Python 代码以从 JIRA 中提取问题。此代码由 Atlassian 提供,他们使用的是 JiraOne 库。
在 Config.Json 文件中,我们包含以下信息。
{
"user": "[email protected]",
"password": "<APITOKEN_HERE>",
"url": "https://nexusfive.atlassian.net"
}
下面是我正在运行的 Python 代码。
from jiraone import LOGIN, issue_export
import json
file = "config.json"
config = json.load(open(file))
LOGIN(**config)
jql = "project in (AB, BC, IT, IP) order by created DESC"
issue_export(jql=jql)
我收到以下错误消息,并且不知道如何解决此问题。
错误信息:
Downloading issue export in CSV format.
<Response [200]> OK ::downloading issues at page: 0 of 9
Traceback (most recent call last):
File "C:\Users\User123\Desktop\PBI Files\Python Scripts\untitled10.py", line 12, in <module>
issue_export(jql=jql)
File "C:\Users\User123\Anaconda3\lib\site-packages\jiraone\reporting.py", line 2189, in export_issues
file_writer(
File "C:\Users\User123\Anaconda3\lib\site-packages\jiraone\reporting.py", line 3223, in file_writer
f.write(content)
File "C:\Users\User123\Anaconda3\lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u03a3' in position 409: character maps to <undefined>
答:
0赞
Marcelo Paco
3/15/2023
#1
要遵循 Prince Nyeche 提供的修复程序,您必须执行以下操作。在文本编辑器中打开文件。转到第 2189 行。它应该看起来像这样:C:\Users\User123\Anaconda3\lib\site-packages\jiraone\reporting.py
file_writer(
folder,
file_name,
content=issues.content.decode(encoding, errors=errors),
mark="file",
mode="w+",
)
添加建议的编辑:
content=issues.content.decode('utf-8', errors="replace"),
保存您的文件。然后重试代码。untitled10.py
评论
jiraone
windows
Oct 31, 2022