두 파일의 다른 줄을 비교하여 빈칸을 없애고 줄 번호를 출력하다

4512 단어
class Compare_Txt():
    def __init__(self,file_path):
        self.file_path = file_path

    def File_Read(self):
        # 
        list_a = []
        with open(self.file_path,'r',encoding='utf-8') as file:
            # , list_a
            a = file.readline()
            while a:
                #strip() ,lstrip() ,rstrip ,list_a.replace(' ','') 
                list_a.append(a.strip())
                a = file.readline()
        # 
        file.close()
        return list_a

if __name__ == '__main__':
    list_file1 = Compare_Txt(r"d:\ 
ew 1.txt"
).File_Read() list_file2 = Compare_Txt(r"d:\
ew 2.txt"
).File_Read() #j j = 0 for i in list_file1: j = j + 1 if i not in list_file2: # 1 2 print(j,i)

인터페이스 출력과 인터페이스 문서의 출력이 일치하는지 비교할 수 있습니다

좋은 웹페이지 즐겨찾기