exam item

#encoding=utf-8

import re
import pdb
q = []
a = []
item = dict()

#P = "(?<=q\d{1}\)).*?(?=a\d{1}\))"
P = "(?<=q\d{1}\)).*?\?"
f = open("cobol.txt", "r").read()
m = re.split("[QA]\d{1,4}\)", f)

for i, j in enumerate(m):
    if i % 2:
        q.append(j.strip().strip('\n'))
    else:
        a.append(j.strip().strip('\n'))
a = a[1:]
for i in range(len(q)):
    item[q[i]] = a[i]

pdb.set_trace()


#if __name__ == '__main__':
#    run()

你可能感兴趣的:(it)