Skip to content

Conversation

@justatrade
Copy link

No description provided.

try:
with open('referat.txt', 'r', encoding='UTF-8') as read_file:
while True:
line = read_file.readline()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

можно сразу все прочитать. Но это не очень хорошо для больших файлов

if not line:
break
else:
read_string += line

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Просто ты все равно весь контент в файла в память сохраняешь, так что смысла чиать по строке мало

try:
with open('referat2.txt', 'w', encoding='UTF-8') as write_file:
write_file.write(read_string.replace('.', '!'))
except (IOError, FileNotFoundError) as e:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

круто что ошибки обрабатываешь

writer.writerow(each)
except (IOError, FileNotFoundError) as e:
print(e)
pprint.pprint(dict_list)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

О знаешь про это принт, он очень удобный для больших объектов

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants