On 24/02/2014 20:48, Dante Loi wrote:
#!/usr/bin/python
import string
import sys
infile = open(sys.argv[1], 'r')
outfile = open(sys.argv[2], 'w')
outfile.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n")
for line in infile.readlines():
if line.strip():
name, value = [ word.strip() for word in line.split("=",1) ]
outfile.write("\t<string name=\"" + name + "\">" + value + "</string>\n")
outfile.write("</resources>")
infile.close()
outfile.close()
se volete proporre qualche miglioria è ben'accetta comunque funziona alla perfezione!
Per l'output puoi dare un'occhiata a format:
http://docs.python.org/2.7/library/stdtypes.html?highlight=format#str.format
Ciao
diego
|
_______________________________________________
Python mailing list
Python@lists.python.it
http://lists.python.it/mailman/listinfo/python