Python - Compare 2 files and output differences

前端 未结 2 701
悲&欢浪女
悲&欢浪女 2021-01-16 06:42

I\'m aiming to write a script that will compare each line within a file, and based upon this comparison, create a new file containing the lines of text which aren\'t in the

2条回答
  •  一整个雨季
    2021-01-16 07:09

    with open("H:/Ast/Hpa.java", encoding="utf8") as f:
        with open("G:/Soft_install/Hpa.java", encoding="utf8") as fe:
            for line in f:
                for linefe in fe:
                    if (line != linefe):
                        print(line)
                        break
                    else:
                        break
    

提交回复
热议问题