图 1 | 图 2 | 图 3 |
f=open("卷 3.txt",encoding="utf-8") line=f.readline().strip() c=0 #strip()用于删除字符串尾部的"\n"换行符 preId=0 QuestionInfo=[ ] |
while line: if line[0] == "【": curId = if curId - preId > 1: for i in range(preId, curId): QuestionInfo.append(str(i)) elif c>0: for i in range(1, c + 1): QuestionInfo.append(str(preId) + "(" + str(i) + ")") c = 0
else:
line=f.readline().strip() #strip()用于删除字符串尾部的"\n"换行符 f.close() print("卷 3 题号划分为: ") for Id in QuestionInfo: print(Id) |