list - Python series writing issue -
i have code writing series in text file
bin = int("377731") open('{0}/{0}.txt'.format(bin)) fine: cc in fine , in range(1000): name = cc[6:11] tg = open('{0}/{1}.txt'.format(bin,name), 'a') tg.write('{0}{1:03}'.format(cc,i)) tg.close() i wanted code write output this
37773100000000 37773100000001 ... but when excute code output shows this
37773100000 000 37773100000 001 ... why code writing ? error?
when iterate on fine (for cc in fine) line with line break, hence linebreak between cc , i.
if display it, see:
>>> cc '37773100000\n' you can trim line using:
cc = cc.strip()
Comments
Post a Comment