字典理解,元组?

Dictionary comprehension, tuples?

我在努力理解

resultList =  [['TWP-883 PASS'], ['TWP-1080 PASS'], ['TWP-1081 PASS']]

result_dicts = [{("issueId","status")[x[0]]:x[1] for x in enumerate(lst[0].split())} for lst in resultList] 

那一行代码。尝试将这种理解方法扩展为经典方式。

x =((0, 'TWP-883'),(1, 'PASS'),(0, 'TWP-1080'),(1, 'PASS'),(0, 'TWP-1081'),(1, 'PASS'))

bew ={("issueId", "status")[x[0][0]]:x[0][0]}

print(bew)

我快要疯了,谁能解释一下这个语法?

您只是要我们解释发生了什么吗?如果是这样的话,还有另外两种写法。

results = []
for i in resultList:
    id, result = i[0].split()
    results.append({"issueId": id, "status": result})
print(results)

res = [{"issueId": x[0], "status": x[1]} for x in [i[0].split() for i in resultList]]
print(res)