-
Notifications
You must be signed in to change notification settings - Fork 0
/
py_anew.py
42 lines (28 loc) · 1018 Bytes
/
py_anew.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
def file_joining():
with open('one.txt', 'r') as f1:
firstfile= frozenset(f1.readlines())
print(firstfile)
with open ('two.txt', 'r') as f2:
secondfile = frozenset(f2.readlines())
print (secondfile)
def file_union(firstfile,secondfile):
thirdfile= (firstfile | secondfile)
#print(thirdfile)
return thirdfile
def file_intersection(firstfile,secondfile):
thirdfile= (firstfile & secondfile)
return thirdfile
def file_difference(firstfile,secondfile):
thirdfile= ( firstfile - secondfile)
return thirdfile
def file_symmetric_difference(firstfile,secondfile):
thirdfile= (firstfile ^ secondfile)
return thirdfile
thirdfile=file_union(firstfile , secondfile)
with open ('third.txt', 'w') as f3:
if thirdfile:
f3.writelines(sorted(thirdfile))
else:
f3.write("\n No new content")
if __name__ =='__main__':
file_joining()