lloyd = {
"name": "Lloyd",
"homework": [90.0,97.0,75.0,92.0],
"quizzes": [88.0,40.0,94.0],
"tests": [75.0,90.0]
}
alice = {
"name": "Alice",
"homework": [100.0, 92.0, 98.0, 100.0],
"quizzes": [82.0, 83.0, 91.0],
"tests": [89.0, 97.0]
}
tyler = {
"name": "Tyler",
"homework": [0.0, 87.0, 75.0, 22.0],
"quizzes": [0.0, 75.0, 78.0],
"tests": [100.0, 100.0]
}
students=[lloyd,alice,tyler]
上面给出的是我的python代码。我想打印出学生列表中的所有数据,就像下面的示例一样。
Lloyd
[90, 97, 75, 92]
[88, 40, 94]
[75, 90]
您可以使用“ For Each”来轻松地在python上使用:
例子:
items = [1,2,3,4]
for item in items:
print item
这会打印我们列表中的所有数字
这里是一个解决方案:
for student in students:
print " ",student['name']
print student['homework']
print student['quizzes']
print student['tests']
希望对您有所帮助!
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句