Python修改AndroidManifest.xml

weixin_33860722發表於2016-03-08
#!/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')

相關文章