d=[{"学号":"201901", "姓名":"张三", "成绩":560},{"学号":201902", "姓名":"李四", "成绩":550},{"学号":"201903","姓名":"王二","成绩":570}] 需要上述错误代码改正后的完整正确代码
时间: 2024-05-17 19:10:30 浏览: 42
学号+姓名.vsd
你提供的数据存在语法错误,请将第二个字典的学号key值的引号补全。
正确的数据格式应该是:
```
d=[{"学号":"201901", "姓名":"张三", "成绩":560},{"学号":"201902", "姓名":"李四", "成绩":550},{"学号":"201903","姓名":"王二","成绩":570}]
```
完整的代码如下:
```python
d=[{"学号":"201901", "姓名":"张三", "成绩":560},{"学号":"201902", "姓名":"李四", "成绩":550},{"学号":"201903","姓名":"王二","成绩":570}]
for i in d:
print(i["学号"],i["姓名"],i["成绩"])
```
输出结果为:
```
201901 张三 560
201902 李四 550
201903 王二 570
```
阅读全文