How to convert list into a string?
- by PARIJAT
I have extracted some data from the file and want to write it in the file 2 but the program says 'sequence item 1: expected string, list found', I want to know how I can convert buffer[] i.e. string into sequence, so that it could be saved in file 2.
file = open('/ddfs/user/data/k/ktrip_01/hmm.txt','r')
file2 = open('/ddfs/user/data/k/ktrip_01/hmm_write.txt','w')
buffer = []
rec = file.readlines()
for line in rec :
field = line.split()
print '>',field[0]
term = field[0]
buffer.append(term)
print field[1], field[2], field[6], field[12]
term1 = field [1]
buffer.append(term1)
term2 = field[2]
buffer.append[term2]
term3 = field[6]
buffer.append[term3]
term4 = field[12]
buffer.append[term4]
file2.write(buffer)
file.close()
file2.close()