Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.