diff options
author | Lan Hui <1348141770@qq.com> | 2021-07-14 15:05:47 +0800 |
---|---|---|
committer | Lan Hui <1348141770@qq.com> | 2021-07-14 15:05:47 +0800 |
commit | 9375d5536c060eaa6c132f7533f8486abfd04074 (patch) | |
tree | 6d88340bb70f9adec6f5a469686609e5777f8160 /example/src |
Upload Jin Xiongrong's work -- https://gitee.com/dragondove/storode; fix UnicodeDecodeError
Diffstat (limited to 'example/src')
-rw-r--r-- | example/src/check_students.py | 60 | ||||
-rw-r--r-- | example/src/myutil/get_student_number.py | 14 |
2 files changed, 74 insertions, 0 deletions
diff --git a/example/src/check_students.py b/example/src/check_students.py new file mode 100644 index 0000000..782eb22 --- /dev/null +++ b/example/src/check_students.py @@ -0,0 +1,60 @@ +# @req 0e96 +import operator +from myutil.get_student_number import get_student_number + +# main + +# @req 0e96 37 +student_no = [ + '201532120139', + '201632120134', + '201632120140', + '201632120149', + '201632120150', + '201632120152', + '201632120161', + '201730210234', + '201732120133', + '201732120134', + '201732120135', + '201732120136', + '201732120137', + '201732120140', + '201732120141', + '201732120142', + '201732120143', + '201732120146', + '201732120147', + '201732120151', + '201732120152', + '201732120157', + '201732120159', + '201732120161', + '201732120164', + '201732120165', + '201732120166', + '201732120167', + '201732120168', + '201732120170', + '201732120173', + '201732120174', + '201732120175', +] + + +assignments = ['assignment-submissions.txt', 'assignment-submissions2.txt'] + +result = [] # @req unkw +for n in student_no: + count = 0 + for fname in assignments: + lst = get_student_number(fname) + if n in lst: + count += 1 + + result.append((n, count)) + +for t in sorted(result, key=operator.itemgetter(1)): + n = t[0] + count = t[1] + print('%s\t%d' % (n, count)) diff --git a/example/src/myutil/get_student_number.py b/example/src/myutil/get_student_number.py new file mode 100644 index 0000000..5f5c22d --- /dev/null +++ b/example/src/myutil/get_student_number.py @@ -0,0 +1,14 @@ +# @req 43b6 +def get_student_number(fname): + f = open(fname, encoding='utf8') + lines = f.readlines() + f.close() + numbers = [] + for line in lines: + line = line.strip() + line = line.replace('\t', ' ') + lst = line.split(' ') + for x in lst: + if len(x) == 12 and x[0] == '2': # @req 43b6:BACK3 + numbers.append(x) + return list(set(numbers)) |