0

无法在 Windows 7 机器上使用 Jira-Python 库将屏幕截图附加到问题。我正在使用“rb”选项打开“.PNG”文件,但仍然UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 208: character maps to <undefined>出现错误。也只有 'r' 打开文件选项,文件被上传,但大小为 0.0 kb。这是代码片段:

from client import JIRA
jira_options={'server': JIRA_URL}
jira=JIRA(options=jira_options,basic_auth=(usrname,passwd))
issue_obj = jira.issue([new_issue_id])
fileimgpath = "C:/installers/abc.PNG"
imgfile = open(fileimgpath,"rb")
jira.add_attachment(issue_obj,imgfile,"abc.PNG")

谢谢你的帮助。

4

1 回答 1

1

你有过:

jira.add_attachment(issue_obj,imgfile,"abc.PNG")

看来您的参数设置错误

请参阅此处的评论:[ https://answers.atlassian.com/questions/138053/jira-python-attached-file-filename]

嗯:刚刚遇到另一个链接:[ http://jira-python.readthedocs.org/en/latest/_modules/jira/client.html] 其中有:

def add_attachment(self, issue, attachment, filename=None):

也许更好用:

jira.add_attachment(issue_obj, attachment=imgfile, filename="abc.PNG")

于 2014-04-22T12:33:55.437 回答