forked from Huangtuzhi/AlibabaRecommand
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUtility.py
38 lines (30 loc) · 807 Bytes
/
Utility.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
#!/usr/bin/python env
# -*- coding: utf-8 -*-
__author__ = 'Huang yi'
class Utility(object):
def __init__(self):
pass
def CheckSame(self, input1, input2):
file1 = open(input1)
file2 = open(input2)
f1 = []
f2 = []
both_list = []
file1.readline()
for line in file1:
f1.append(line.rstrip())
file2.readline()
for line in file2:
f2.append(line.rstrip())
for e in f1:
if e in f2:
both_list.append(e)
print '相同元素:'
print both_list
print '相同个数:'
print len(both_list)
file1.close()
file2.close()
if __name__ == '__main__':
tool = Utility()
tool.CheckSame('file3.txt', 'file2.txt')