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)

调整后,输出:

 

你可能感兴趣的:(ValueError: too many values to unpack (expected 2))