python编程,报错如下:(有知道如何改的嘛,麻烦教一下)
import argparse
import re
# 命令行解析
ap = argparse.ArgumentParser()
ap.add_argument('-i', '--input', required=True,
help='path to the iBug 300-W XML file')
ap.add_argument('-t', '--output', required=True,
help='path to the data split XML eye only')
args = vars(ap.parse_args)
# 正则表达式匹配
LANDMARKS = set(list(range(36, 48)))
PART = re.compile("part name='[0-9]+'")
print("[info] parsing XML file")
rows = open(args['input']).read().strip().split('\n')
output = open(args['output'], 'w')
for row in rows:
parts = re.findall(PART, row)
if len(parts) == 0:
output.write('{}\n'.format(row))
else:
attr = " name='"
i = row.find(attr)
j = row.find("'", i + len(attr) + 1)
name = int(row[i + len(attr):j])
if name in LANDMARKS:
output.write("{}\n".format(row))
output.close()