版权声明:本文为Jumbo原创文章,采用[知识共享 署名-非商业性使用-禁止演绎 4.0 国际 许可协议],转载前请保证理解此协议
原文出处://www.greatytc.com/p/aaa04f35535a
#!/usr/bin/pyton
# coding=utf-8
from xml.dom import minidom
import codecs
def modifyVersion(filename, versionCode, versionName):
doc = minidom.parse(filename)
root = doc.documentElement
root.setAttribute('android:versionCode', versionCode)
root.setAttribute('android:versionName', versionName)
f = file(filename, "w")
writer = codecs.lookup('utf-8')[3](f)
doc.writexml(writer, newl='', indent='\n', encoding='utf-8')
writer.close()
f.close()
if __name__ == '__main__':
modifyVersion('D:\\proj\\Demo\\AndroidManifest.xml', '10', '1.0.0.10')