生成准考证

所属作业: 文件 数据结构: 列表 算法: 排序

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
students = list(open("students.txt", "r", encoding="utf-8"))
del students[0]
for student in students:
    data_students = student.strip().split(",")
    writer = open("%s.txt" % data_students[1], "w")
    writer.write(
        "大学英语四级考试\nCET4\n准考证\n准考证号:%s\n考生姓名:%s\n考场号:%s\n座位号:%s\n学校名称:%s\n学院系别:%s\n备注:考试须携带准考证、学生证、身份证参加考试"
        % (
            data_students[1],
            data_students[0],
            data_students[2],
            data_students[3],
            data_students[4],
            data_students[5],
        )
    )
    writer.close()
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
students = open("数据/students.txt", "r", encoding="utf-8")
students.readline()
while True:
    data_students = students.readline().strip().split(",")
    if len(data_students) == 1:
        break
    writer = open("temp/%s.txt" % data_students[1], "w")
    writer.write(
        "大学英语四级考试\nCET4\n准考证\n准考证号:%s\n考生姓名:%s\n考场号:%s\n座位号:%s\n学校名称:%s\n学院系别:%s\n备注:考试须携带准考证、学生证、身份证参加考试"
        % (
            data_students[1],
            data_students[0],
            data_students[2],
            data_students[3],
            data_students[4],
            data_students[5],
        )
    )
    writer.close()
students.close()
1
2
3
4
len("".split(","))
len("".split(" "))
len("".split())
以上计算结果分别是什么