Как вывести несколько переменных с похожим названием разом?
Как сделать чтобы переменная "av" собирала информацию об установленных антивирусах и выводила все установленные одной переменной? Извините за глупый вопрос, я новичок в python.
Как пример: Windows Defender, Avast, ESET
import os
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\\Avira\\Launcher'):
av = 'Avira'
if os.path.exists('C:\\Program Files\\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\\COMODO\\COMODO Internet Security'):
av = 'Comodo'
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\\GRIZZLY Antivirus'):
av = 'Grizzly Pro'
if os.path.exists('C:\\Program Files\\Kaspersky Lab'):
av = 'Kaspersky'
if os.path.exists('C:\\Program Files\\IObit\\IObit Malware Fighter'):
av = 'Malvare fighter'
if os.path.exists('C:\\Program Files\\Norton Security'):
av = 'Norton'
if os.path.exists('C:\\Program Files\\Panda Security\\Panda Security Protection'):
av = 'Panda Security'
if os.path.exists('C:\\Program Files\\360\\Total Security'):
av = '360 Total Security'
print(av)
Ответы (1 шт):
Автор решения: Aimon Z.
→ Ссылка
import os
avs = list()
if os.path.exists('C:\\Program Files\\Windows Defender'):
avs.append('Windows Defender');
if os.path.exists('C:\\Program Files\\AVAST Software\\Avast'):
avs.append('Avast');
if os.path.exists('C:\\Program Files\\AVG\\Antivirus'):
avs.append('AVG');
if os.path.exists('C:\\Program Files\\Avira\\Launcher'):
avs.append('Avira');
if os.path.exists('C:\\Program Files\\IObit\\Advanced SystemCare'):
avs.append('Advanced SystemCare');
if os.path.exists('C:\\Program Files\\Bitdefender Antivirus Free'):
avs.append('Bitdefender');
if os.path.exists('C:\\Program Files\\COMODO\\COMODO Internet Security'):
avs.append('Comodo');
if os.path.exists('C:\\Program Files\\DrWeb'):
avs.append('Dr.Web');
if os.path.exists('C:\\Program Files\\ESET\\ESET Security'):
avs.append('ESET');
if os.path.exists('C:\\Program Files\\GRIZZLY Antivirus'):
avs.append('Grizzly Pro');
if os.path.exists('C:\\Program Files\\Kaspersky Lab'):
avs.append('Kaspersky');
if os.path.exists('C:\\Program Files\\IObit\\IObit Malware Fighter'):
avs.append('Malware fighter');
if os.path.exists('C:\\Program Files\\Norton Security'):
avs.append('Norton');
if os.path.exists('C:\\Program Files\\Panda Security\\Panda Security Protection'):
avs.append('Panda Security');
if os.path.exists('C:\\Program Files\\360\\Total Security'):
avs.append('360 Total Security');
for av in avs:
print(av);