python对比语言文件输出等号前面不同的行.py
发布时间:2020-05-25 00:50:11 所属栏目:Python 来源:互联网
导读:python对比语言文件输出等号前面不同的行.py
|
下面是脚本之家 jb51.cc 通过网络收集整理的代码片段。 脚本之家小编现在分享给大家,也给大家做个参考。 """
python对比语言文件输出等号前面不同的行.py
http://www.bathome.net/thread-38064-1-2.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)
以上是脚本之家(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。 如果觉得脚本之家网站内容还不错,欢迎将脚本之家网站推荐给程序员好友。 (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
