[Tutor] a quick Q: how to use for loop to read a series of files with .doc end
lina
lina.lastname at gmail.com
Sat Oct 8 05:34:05 CEST 2011
Another minor derived questions:
summary=[]
for a,b in zip(results['E'],results['B']):
summary.append(a+b) ## now the summary is '[0,1, 3, 5,
6,0,0,0]'
del summary[0] ## here I wanna remove the first zero, which came
from the initial double quote "EB...E",
summary.pop() ## here I wanna remove the last three zeros
summary.pop()
summary.pop()
print(summary) ### output is [1,3,5,6]
summary='\n'.join(str(summary).split(',')) ### wish the result in
one column,
with open(base+OUTFILEEXT,"w") as f:
f.write(str(summary))
the final result in the output.txt file is:
[1
3
5
6]
Q1: how can I remove the [1 "[" to only keep 1?
Q2 how can I improve above expressions?
Thanks,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20111008/4da0e138/attachment.html>
More information about the Tutor
mailing list