1 #Coding:utf-82 #! /usr/bin/python3 fromDifflibImport*4 ImportSYS5 ImportOS6 Reload (SYS)7Sys.setdefaultencoding ("Utf-8" )8 fromTkinterImport*9 ImportTkfiledialog;Ten ImportTkmessagebox; One Aroot=Tk (); -Root.geometry ("280x300+983+630"); -Root.attributes ("-alpha", 1) theRoot.attributes ("-topmost", 1); -Root.title= ("contrast"); - -filename2 = tkfiledialog.askopenfilename (Initialdir ='C:\Python'); +Label1=label (root,text=filename2); - Label1.pack (); + AFilename4 = tkfiledialog.askopenfilename (Initialdir ='C:\Python'); atLabel2=label (root,text=filename4); - Label2.pack (); - - defdiffcommand (filename): -FileHandle = open (filename,"RB") -text=Filehandle.read (). Splitlines () in filehandle.close () - returntext to + defdiffbtn (): - iffilename2=="" orfilename4=="": theTkmessagebox.showinfo ("Sorry","Please Select File") * Else: $text1_lines=Diffcommand (filename2)Panax Notoginsengtext2_lines=Diffcommand (filename4) -s=Htmldiff.make_file (Htmldiff (), Text1_lines,text2_lines) theF=open (R"C: \ comparison results. HTML",'W') + F.write (s) A f.close () the +Button (root,text="contrast", state=active,bg="Blue", command=diffbtn). Pack (side=Left ) -Root.mainloop ()Thinter
Python Development text File comparison