fileread_practice.py 704 Bytes
def print_menu():
    import sys
    import io
    
    f1 = io.open(sys.argv[1], "r", encoding="utf-8")
    f2 = io.open(sys.argv[2], "r", encoding="utf-8")
    list_compare = list()

    list1 = []
    for i in list(f1):
        list1.append(i)

    list2 = []
    for i in list(f2):
        list2.append(i)

    for i in list1:
        if i in list2:
            list_compare.append(i)

    list_compare_fixed = [item.strip() for item in list_compare]
    
    fl = open(sys.argv[3],'w')
    for i in list_compare_fixed:
        I=i.encode('utf8')
        fl.write(I)
        fl.write('\n')
    fl.close()
    
    print("complete!")
    sys.stdout.flush()

if __name__ == '__main__':
    print_menu()