Not a member of GistPad yet?
Sign Up,
it unlocks many cool features!
- # Импортируем модуль os для работы с путями и файловой системой
- import os
- # Запрашиваем ФИО пациента (текст приглашения выводится через input, не через print)
- full_name_input = input("Enter the full name of the patient separated by space (Ivanov Ivan Ivanovich)\n")
- # Запрашиваем дату приёма, который нужно посмотреть
- visit_date = input("Enter the date of the appointment you want to see\n")
- # Разбиваем ФИО по пробелам и приводим каждое слово к виду "С большой буквы"
- # (чтобы поиск не зависел от регистра ввода), соединяем через "_"
- parts = full_name_input.strip().split()
- patient_folder = "_".join(part.capitalize() for part in parts)
- # Собираем путь до папки пациента: patients/{Ф_И_О}
- patient_path = os.path.join("patients", patient_folder)
- # Если папки с таким пациентом нет — выводим сообщение и завершаем программу
- if not os.path.isdir(patient_path):
- print("there is not such patient!")
- else:
- # Строим путь до файла приёма по введённой дате
- visit_path = os.path.join(patient_path, "visits", visit_date)
- # Если файл приёма существует — читаем и выводим его содержимое
- if os.path.isfile(visit_path):
- with open(visit_path, "r", encoding="utf-8") as f:
- print(f.read())
- else:
- # Если файла нет — выводим сообщение об ошибке
- print("There was no such appoinment with the doctor")
RAW Paste Data
Copied
Advertisement
