Advertisement
plarmi

workpython_16_9

Jun 24th, 2023
677
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.77 KB | None | 0 0
  1. import os
  2.  
  3. input_file_path = 'файл.txt'
  4.  
  5. # Проверяем существование файла
  6. if not os.path.isfile(input_file_path):
  7.     print(f'Файл {input_file_path} не найден.')
  8.     exit()
  9.  
  10. # Получаем размер файла в байтах
  11. file_size = os.path.getsize(input_file_path)
  12.  
  13. print(f'Размер файла {input_file_path}: {file_size} байт')
  14.  
  15. # Открываем файл для чтения
  16. with open(input_file_path, 'r') as input_file:
  17.     # Считываем содержимое файла
  18.     content = input_file.read()
  19.  
  20. # Подсчитываем количество символов
  21. character_count = len(content)
  22.  
  23. print(f'Количество символов в файле: {character_count}')
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement