Как оптимизировать данный код чтобы получилось минимальное количество строчек?
Возможно ли добавить все пути в список чтобы потом уже выводить название установленного ПО.
if os.path.exists('C:\\Program Files\\Windows Defender'):
av = 'Windows Defender'
if os.path.exists('C:\\Program Files\\AVAST Software\\Avast'):
av = 'Avast'
if os.path.exists('C:\\Program Files\\AVG\\Antivirus'):
av = 'AVG'
if os.path.exists('C:\\Program Files (x86)\\Avira\\Launcher'):
av = 'Avira'
if os.path.exists('C:\\Program Files (x86)\\IObit\\Advanced SystemCare'):
av = 'Advanced SystemCare'
if os.path.exists('C:\\Program Files\\Bitdefender Antivirus Free'):
av = 'Bitdefender'
if os.path.exists('C:\\Program Files\\DrWeb'):
av = 'Dr.Web'
if os.path.exists('C:\\Program Files\\ESET\\ESET Security'):
av = 'ESET'
if os.path.exists('C:\\Program Files (x86)\\Kaspersky Lab'):
av = 'Kaspersky'
if os.path.exists('C:\\Program Files (x86)\\360\\Total Security'):
av = '360 Total Security'
else:
pass
Ответы (1 шт):
Автор решения: vadim vaduxa
→ Ссылка
folders = {'c:\\folder_1': 'name_1', 'c:\\folder_2': 'name_2', }
names = [folders[d] for d in filter(os.path.exists, folders)]