1 ImportSYS2 ImportRe3 4 #argv is a list of the paths to the file5 defErase_mark (args):6Mark = Re.sub ("//*. {1,1000}/*/","", args)7Mark = Re.sub ("//. {1,1000}\n","", Mark)8Mark = Re.sub ("#. {1,1000}\n","", Mark)9 returnMarkTen One deferase_space (args): ASpace = Args.replace (" ","") -Space = Space.replace ("\ n","") - returnSpace the - defshow_different (args_one,args_two): -info ="[decument One:%s decument:%s]"%(Args_one,args_two) - Print(Info) + - + defdisplay (information,condition): A ifCondition: at Print(information[0]) - Else: - Print(information[1]) - - - defCompare_same (args_one,args_two): inCycle = Args_oneifLen (Args_one) < Len (args_two)ElseArgs_two - forIinchRange (len (cycle)): to ifArgs_one[i]! =Args_two[i]: + show_different (Args_one[i],args_two[i]) -Display (["Decument is alike","Decument is different"], Args_one = =args_two) the * $ defachieve (args):Panax NotoginsengCover = open (args["Decument_one"], mode ="R", encoding ="Utf-8") -Primary = open (args["Decument_two"], mode ="R", encoding ="Utf-8") theCover_info, Primary_info =Cover.read (), Primary.read () +Cover_info, Primary_info =Erase_mark (Cover_info), Erase_mark (Primary_info) ACover_info, Primary_info =Erase_space (Cover_info), Erase_space (Primary_info) the compare_same (Cover_info, Primary_info) + - $ defMain (): $ ifLen (SYS.ARGV) < 3: -First_file,second_file = input ("decoment One path:"). Strip (), input ("decoment the path:"). Strip () - Else: theFirst_file,second_file = sys.argv[1],sys.argv[2]; -args = {"Decument_one": First_file,"Decument_two": Second_file};Wuyi achieve (args) the - Wu if __name__=="__main__": -Main ()
Python-written C + + code comparison