How to combine two file with only have some match var and print that had match
file1.txt
email@email.com b5c2eac4f288490166fe508d77652aea:R7pnHzu94YC81ZYGxtbKyWHzHbF3err0 email@email.com b850c37a676df2cba45a70917be69737:w4YcDLcGb1EP3FMszaChlc1ISJ4WMKmc
file2.txt
b5c2eac4f288490166fe508d77652aea:R7pnHzu94YC81ZYGxtbKyWHzHbF3err0:123456x b850c37a676df2cba45a70917be69737:w4YcDLcGb1EP3FMszaChlc1ISJ4WMKmc:12345678x
Output
email@email.com:123456x email@email.com:12345678x
Try code
with open('file1.txt') as file1, open('file2.txt') as file2: for line in file1: data = line.split(" ") md5 = data[1].strip() email = data[0].strip() for line2 in file2: data2 = line.split(":") passwd = data2[1].strip() if data2[0].strip() == md5:
https://stackoverflow.com/questions/65746025/combine-var-in-2-file-with-only-have-match-some-var-python January 16, 2021 at 10:51AM
没有评论:
发表评论