-
Notifications
You must be signed in to change notification settings - Fork 214
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,17 @@ def main(): | |
Эта функция вызывается автоматически при запуске скрипта в консоли | ||
В ней надо заменить pass на ваш код | ||
""" | ||
pass | ||
with open('referat.txt', 'r', encoding='utf-8') as f: | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Попробуй выделить отдельные функции: read_file, write_file, process_file_content |
||
|
||
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 commentThe reason will be displayed to describe this comment to others. Learn more. здесь так же можно использовать as f, потому что область видимости предыдущего f только блок with |
||
new_f.write(replace_example) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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.
Должно ок работать без указания кодировки. Если не указываешь кодировку - код чутьчуть универсальнее получается.