我正在阅读一个xml
文件,找到四位数据,然后在数据库中更新。我的问题是如何更有效地搜索它们。在这种情况下,一行一行是最好的吗?我正在把整个文件读入一个变量,然后对它进行搜索
with open(cur_file, 'rb') as xml_file:
bill_mgr_email_re = re.compile(r'<BillingManagerInformation .* Email="(.*.com)"')
num_bills_re = re.compile(r'NumberBills="(\d+)"')
num_ebills_re = re.compile(r'NumberOfEbills="(\d+)"')
num_mailed_re = re.compile(r'NumberOfMailedDocs="(\d+)"')
data = xml_file.read()
bill_mgr_email = bill_mgr_email_re.search(data).group(1)
num_bills = num_bills_re.search(data).group(1)
num_ebills = num_ebills_re.search(data).group(1)
num_mailed = num_mailed_re.search(data).group(1)
目前没有回答
相关问题 更多 >
编程相关推荐