ValueError: too many values to unpack (expected 2)

循环一个字典时报错:

数据:{‘O_DATA’: [{‘ACCOUNT’: ‘A20001002’, ‘ZACTOSP’: Decimal(‘21792635.96’), ‘ZBUDGET’: Decimal(‘290271.50’), ‘ZACTUAL’: Decimal(‘4878563.10’)}]}

代码:

    for key, value in response.data['O_DATA'][0]:
        print(key, value)

循环字典的时候忘了items()

    for key, value in response.data['O_DATA'][0].items():
        print(key, value)

调整后,输出:

 

转载于:https://www.cnblogs.com/jinyin/p/10683880.html