Почему файл остается пустым?
В первом файле находится: a3b4c2e10b1 Во второй должно записаться: aaabbbbcceeeeeeeeeeb
import re
my_str=''
with open ('dataset_3363_2.txt') as file_in, open("1.txt", 'w') as file_out:
for el in re.findall(r'(\w)(\d+)', file_in):
my_str += el[0]*int(el[1])
file_out.write(my_str)
Ответы (2 шт):
Автор решения: вася
→ Ссылка
https://repl.it/repls/DeliciousDirectSection
import re
my_str=''
with open ('dataset_3363_2.txt') as file_in, open("1.txt", 'w') as file_out:
for el in re.findall(r'(\w)(\d+)', file_in.read()):
my_str += el[0]*int(el[1])
file_out.write(my_str)