我的 python 代码遇到了问题。我有一个循环设置的字典来存储我的数据。但是,我收到 PropertyHolder 对象没有多个字段的属性错误。如果我只考虑有此错误的前两个字段,我就能让代码工作,但是当我向代码添加第三个字段时,输出只为所有三个字段提供 None 而不是确实存在的值。我试图找出一种使用 getattr 函数的方法,但没有成功。我对 python 很陌生。为了简单起见,我只提供了一部分代码。任何帮助表示赞赏。
columnslist = [
'Story_ID',
'Assignee',
'Story Points'
'Deployment_Date',
'Organization'
]
data = []
for singleIssue in issues:
try:
if singleIssue.fields.assignee is None or singleIssue.fields.customfield_10104 is None: # Check if assignee is None
fields = (
'{}'.format(singleIssue.key),
'No Assignee',
'{}'.format(singleIssue.fields.customfield_10106),
'{}'.format(singleIssue.fields.customfield_13004),
'{}'.format(singleIssue.fields.customfield_11103)
)
else:
fields = (
'{}'.format(singleIssue.key),
'{}'.format(singleIssue.fields.assignee.name),
'{}'.format(singleIssue.fields.customfield_10106),
'{}'.format(singleIssue.fields.customfield_13004),
'{}'.format(singleIssue.fields.customfield_11103)
)
except AttributeError:
if singleIssue.fields.assignee is None or singleIssue.fields.customfield_10104 is None: # Check if assignee is None
fields = (
'{}'.format(singleIssue.key),
'No Assignee',
'None',
'None',
'None'
)
else:
fields = (
'{}'.format(singleIssue.key),
'{}'.format(singleIssue.fields.assignee.name),
'None',
'None',
'None'
)
data.append(fields)
dfJira = pd.DataFrame(data, columns = columnslist )
print(dfJira)