-
Notifications
You must be signed in to change notification settings - Fork 215
for review #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
for review #42
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Принято. Можно что-то поулучшать, но и так ок.
|
||
replace_example = context.replace('.', '!') | ||
print(replace_example) | ||
with open('referat1.txt', 'w', encoding='utf-8') as new_f: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
здесь так же можно использовать as f, потому что область видимости предыдущего f только блок with
@@ -16,7 +16,17 @@ def main(): | |||
Эта функция вызывается автоматически при запуске скрипта в консоли | |||
В ней надо заменить pass на ваш код | |||
""" | |||
pass | |||
with open('referat.txt', 'r', encoding='utf-8') as f: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Должно ок работать без указания кодировки. Если не указываешь кодировку - код чутьчуть универсальнее получается.
context = f.read() | ||
print(len(context)) | ||
number_of_words = len(context.split()) | ||
print(f'Количество слов составляет - {number_of_words}') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Попробуй выделить отдельные функции: read_file, write_file, process_file_content
No description provided.