英文:
'NoneType' object has no attribute 'name' Jira issue type
问题
以下是翻译好的部分:
我是新手学习Python。我尝试获取Jira数据,但在单个问题的`assignee.name`上一直遇到`NoneType`错误。我明白为什么会出现这个错误,只是不确定如何解决它。
columnslist = ['Story', 'Assignee']
data = []
for singleIssue in jira.search_issues(jql_str):
fields = (
'{}'.format(singleIssue.key),
'{}'.format(singleIssue.fields.assignee.name)
)
data.append(fields)
dfJira = pd.DataFrame(data, columns=columnslist)
如果需要任何进一步的帮助,请随时告诉我。
英文:
I am new to python. I am trying to pull Jira data and I keep getting a NoneType error on the singleIssue.fields.assignee.name. I understand why I am getting the error, I am just unsure how to resolve it.
columnslist = ['Story', 'Assignee']
data = []
for singleIssue in jira.search_issues(jql_str):
fields = (
'{}'.format(singleIssue.key),
'{}'.format(singleIssue.fields.assignee.name)
)
data.append(fields)
dfJira = pd.DataFrame(data, columns = columnslist )
答案1
得分: 1
抱歉,你的代码部分包含了许多 HTML 实体编码,我将提供一个翻译清晰的版本如下:
出现 `'NoneType' object has no attribute 'name' Jira issue type` 错误的原因是 Jira 问题没有分配给任何人(**没有受让人**)。您可以在将其添加到 `fields` 元组之前检查问题是否已经被分配。像这样:
columnslist = ['Story', 'Assignee']
data = []
for singleIssue in jira.search_issues(jql_str):
if singleIssue.fields.assignee is None: # 检查是否未分配受让人
# 在受让人为 None 的情况下执行所需操作
fields = (
'{}'.format(singleIssue.key),
'未分配'
)
else:
# 在有受让人的情况下执行所需操作
fields = (
'{}'.format(singleIssue.key),
'{}'.format(singleIssue.fields.assignee.name)
)
data.append(fields)
dfJira = pd.DataFrame(data, columns=columnslist)
英文:
The reason you are getting the 'NoneType' object has no attribute 'name' Jira issue type
error is because the Jira issue has no assignee to it. What you can do is check if the issue has been assigned before adding it to the fields
tuple. Like so:
columnslist = ['Story', 'Assignee']
data = []
for singleIssue in jira.search_issues(jql_str):
if singleIssue.fields.assignee is None: # Check if assignee is None
# Do what you like in the case that it is None
fields = (
'{}'.format(singleIssue.key),
'No Assignee'
)
else:
# Do what you like in the case that there is an assignee available
fields = (
'{}'.format(singleIssue.key),
'{}'.format(singleIssue.fields.assignee.name)
)
data.append(fields)
dfJira = pd.DataFrame(data, columns=columnslist)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论