ValueError: too many

2023-01-31 00:01:31 valueerror

循环一个字典时报错:

数据:{'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)

调整后,输出:

 

相关文章