string - PYTHON several times print from a reference file -


i have question python programming.

if have reference file (ref.txt) like

3 5 6 

i want make output file if want 5 times these strings

3 5 6 3 5 6 3 5 6 3 5 6 3 5 6 

total 15 rows.

i have thought code like

with open('ref.txt') f1, open('out.txt', 'w') f2:      in range(1, 6):            line in f1:                value=line.split()                line=' '.join(value) + '\n'                 f2.write(line) 

this code print original value. how print multiple repeat lines of reference value.

thanks.

repeat = "" open('ref.txt') f1:     line in f1:         repeat = "".join([repeat, line]) open('out.txt', 'w') f2:     f2.write(repeat*5) 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -