EC2 Default User

fix fileread.py to read file using variables

1 +def print_menu():
2 + import sys
3 + import io
4 +
5 + f1 = io.open(sys.argv[1], "r", encoding="utf-8")
6 + f2 = io.open(sys.argv[2], "r", encoding="utf-8")
7 + list_compare = list()
8 +
9 + list1 = []
10 + for i in list(f1):
11 + list1.append(i)
12 +
13 + list2 = []
14 + for i in list(f2):
15 + list2.append(i)
16 +
17 + for i in list1:
18 + if i in list2:
19 + list_compare.append(i)
20 +
21 + list_compare_fixed = [item.strip() for item in list_compare]
22 +
23 + fl = open("/home/ec2-user/menu_recommand_webpage-1/CHATBOT/final.txt",'w')
24 + for i in list_compare_fixed:
25 + I=i.encode('utf8')
26 + fl.write(I)
27 + fl.write('\n')
28 + fl.close()
29 +
30 + print("complete!")
31 + sys.stdout.flush()
32 +
33 +if __name__ == '__main__':
34 + print_menu()
...\ No newline at end of file ...\ No newline at end of file