版權聲明:本文為Jumbo原創(chuàng)文章,采用[知識共享 署名-非商業(yè)性使用-禁止演繹 4.0 國際 許可協(xié)議]残邀,轉(zhuǎn)載前請保證理解此協(xié)議
原文出處:http://www.reibang.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')