答案 0 :(得分:1)
答案 1 :(得分:1)
与该问题相对应的另一个可能是database = open("database", "r")
template = open("template", "r")
outfile1 = open("junk1", "w")
outfile2 = open("junk2", "w")
outfile3 = open("junk3", "w")
for line in database:
part = line.split("|")
title = part[0] #replaces #1
firstname = part[1] #replaces #2
lastname = part[2] #replaces #3
address = part[3] #replaces #4
city = part[4] #replaces #5
state = part[5] #replaces #6
zipcode = part[6] #replaces #7
for line in template:
string = line
for r in (("|1|",title),("|2|", firstname),("|3|", lastname),("|4|", address),("|5|", city),("|6|", state),("|7|", zipcode)):
string = string.replace(*r)
outfile1.write(string)
outfile2.write(string)
outfile3.write(string)
outfile1.close()
outfile2.close()
outfile3.close()
database.close()
template.close()
。