file = open("sus.txt", "r", encoding='utf-8')
file = open("sus.txt", "r", encoding='utf-8')
n = 0
a = []
r = 0
for line in file:
n += 1
a.append(line)
if n == 500:
r += 1
q = open(str(r), 'w+', encoding='utf-8')
q.writelines(a)
a = []
q.close()
n = 0
with open("sus.txt", "r", encoding='utf-8') as source:
idx = 1 # номер файла-приёмника
go = True
while go:
with open(f'part{idx}.txt', 'w', encoding='utf-8') as dest:
for _ in range(500): # не более 500 строк в каждый файл
line = source.readline()
if not line: # пустая строка = конец файла
go = False
break
dest.write(line)
idx += 1