Showing
1 changed file
with
22 additions
and
0 deletions
fileread_practice.py
0 → 100644
| 1 | +f1 = open("C:\\Users\\menu_recommand_webpage\\ect.txt", "r", encoding="utf-8") | ||
| 2 | +f2 = open("C:\\Users\\menu_recommand_webpage\\water.txt", "r", encoding="utf-8") | ||
| 3 | + | ||
| 4 | +list_compare = list() | ||
| 5 | + | ||
| 6 | +list1 = [] | ||
| 7 | +for i in list(f1): | ||
| 8 | + list1.append(i) | ||
| 9 | + | ||
| 10 | +list2 = [] | ||
| 11 | +for i in list(f2): | ||
| 12 | + list2.append(i) | ||
| 13 | + | ||
| 14 | +for i in list1: | ||
| 15 | + if i in list2: | ||
| 16 | + list_compare.append(i) | ||
| 17 | + | ||
| 18 | +list_compare_fixed = [item.strip() for item in list_compare] | ||
| 19 | +print(list_compare_fixed) | ||
| 20 | + | ||
| 21 | +f1.close() | ||
| 22 | +f2.close() |
-
Please register or login to post a comment