使用说明:
将所有需要阅卷的答案按照以下格式放到一个target.txt文档中:
姓名+空格+答案1+答案2
多个学生请换行隔开
如:
学生1 A B B B C B B B BD C D C D B B C B B A AB C D C C B C B C B C D B B B B D C C D D B D A B D A B B D C
学生2 A B B B C B B B BD C D B D A B C B B A AB C D C C B C B C B C D B B B B D C C D D B D A B D A B B D C
将答案按照相同格式放到answer.txt:
如:
答案 A B B C A D B B BD C D C D B C C B B D AC C D C A B C B A B C C C B B B C C C D D B D A B D A C B D C
结果:
# -*- coding: utf-8 -*-
"""
-------------------------------------------------
@ Author :Lan
@ Blog :www.lanol.cn
@ Date : 2020/7/2
@ Description:I'm in charge of my Code
-------------------------------------------------
"""
with open('ans/answer.txt', 'r', encoding='utf8') as f:
answer = f.read().split(' ')
with open('ans/target.txt', 'r', encoding='utf8') as f:
students = f.read()
students = [stu.split(' ') for stu in students.split('
')]
result = {}
for i in students:
result[i[0]] = 0
for index, j in enumerate(answer):
if i[index] == j:
result[i[0]] += 2
print(result)
评论 (0)