Sep-14-2022, 09:32 AM
Just for getting the bitcoins, I made 2 sets of random ip4 addresses.
To compare them is easy. Any other junk in your text files that is not 15 characters long can easily be excluded.
To compare them is easy. Any other junk in your text files that is not 15 characters long can easily be excluded.
import random def makeIP(): mylist = [] for j in range(4): # the bigger the number X in random.randint(1, X), the less chance of overlap num = random.randint(1, 10) mylist.append(str(num)) mystring = '.'.join(mylist) mystring = mystring + '\n' return mystring path2txt = '/home/pedro/myPython/random/' with open(path2txt + 'ip1.txt', 'w') as ip1: ipstring = '' for i in range(1000): ip = makeIP() ipstring = ipstring + ip ip1.write(path2txt + ipstring) with open(path2txt + 'ip2.txt', 'w') as ip2: ipstring = '' for i in range(1000): ip = makeIP() ipstring = ipstring + ip ip2.write(path2txt + ipstring) with open(path2txt + 'ip1.txt') as ip: mylist = ip.readlines() myset1 = set(mylist) with open(path2txt + 'ip2.txt') as ip: mylist = ip.readlines() myset2 = set(mylist) # get the intersection of myset1 and myset2 intersect = myset1 & myset2 difference1_2 = myset1 - myset2 difference2_1 = myset2 - myset1