无法遍历数组

时间:2017-05-24 10:03:45

标签: python arrays loops

我尝试使用Python插入以下工作日志JSON字段,但是我似乎无法在Python中循环数组。

请参阅下面的代码段:

try:
    worklogs_to_insert = []
    for i in issue.fields.worklog["worklogs"]:
        worklogs_to_insert.append(i)
except AttributeError as e:
    log.info("Something went wrong when processing worklogs. :(")
    log.info(e)

运行脚本时出现以下错误:

Something went wrong when processing worklogs. :(
type object 'PropertyHolder' has no attribute 'worklog'

1 个答案:

答案 0 :(得分:0)

尝试使用

for i in issue.fields.worklog.raw["worklogs"]