用户登录
用户注册

分享至

python对比语言文件输出等号前面不同的行.py

  • 作者: 一筒__自摸
  • 来源: 51数据库
  • 2022-08-12
"""
python对比语言文件输出等号前面不同的行.py
http://www.51sjk.com/Upload/Articles/1/0/320/320462_20220812154329102.html
依山居 13:41 2015/11/24
"""
import re
with open("zh_CN.lang",encoding="utf-8") as f:
    zh=f.read()
rec=re.compile("(.+)=(.*)\n")
zht=re.findall(rec,zh)

with open("en_US.lang",encoding="utf-8") as f:
    en=f.read()
    ent=re.findall(rec,en)
    
notinen=[e+"="+c+"\n" for e,c in zht if (e not in en)]
notinzh=[k+"="+v+"\n" for k,v in ent if (k not in zh)]

with open("diff.txt","w+",encoding="utf-8") as f:
    if len(notinen)>=1:
        f.writelines(['zh文件比en文件多出的行:\n']+notinen)
    if len(notinzh)>=1:
        f.writelines(['en文件比zh文件多出的行:\n']+notinzh)
软件
前端设计
程序设计
Java相关