From 645c3eed00ccc23e4d0e1987b094b6daf9a43301 Mon Sep 17 00:00:00 2001 From: Zpadger <31385823+Zpadger@users.noreply.github.com> Date: Mon, 23 Dec 2019 22:40:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=BA=86=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 注释处的程序是正确的,原程序运行错误,得到的成绩表全都是最后一位学生的成绩 --- Day01-15/code/Day07/scoretable.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Day01-15/code/Day07/scoretable.py b/Day01-15/code/Day07/scoretable.py index 188e4e6..4d7ae8f 100644 --- a/Day01-15/code/Day07/scoretable.py +++ b/Day01-15/code/Day07/scoretable.py @@ -11,18 +11,18 @@ def main(): names = ['关羽', '张飞', '赵云', '马超', '黄忠'] subjs = ['语文', '数学', '英语'] scores = [[0] * 3] * 5 - for row, name in enumerate(names): - print('请输入%s的成绩' % name) - for col, subj in enumerate(subjs): - scores[row][col] = float(input(subj + ': ')) - print(scores) -# for row, name in enumerate(names): -# print('请输入%s的成绩' % name) -# scores[row] = [None] * len(subjs) -# for col, subj in enumerate(subjs): -# score = float(input(subj + ': ')) -# scores[row][col] = score -# print(scores) +# for row, name in enumerate(names): +# print('请输入%s的成绩' % name) +# for col, subj in enumerate(subjs): +# scores[row][col] = float(input(subj + ': ')) +# print(scores) + for row, name in enumerate(names): + print('请输入%s的成绩' % name) + scores[row] = [None] * len(subjs) + for col, subj in enumerate(subjs): + score = float(input(subj + ': ')) + scores[row][col] = score + print(scores) if __name__ == '__main__': main()