ЕГЭ 9 задание
This commit is contained in:
22
546456.py
22
546456.py
@@ -0,0 +1,22 @@
|
||||
def percent_ok(log_filename):
|
||||
total_reguest = 0
|
||||
successfull_reguest = 0
|
||||
try:
|
||||
with open(log_filename,'r',encoding='utf-8') as f:
|
||||
for line in f:
|
||||
if not line.strip():
|
||||
continue
|
||||
|
||||
total_reguest+=1
|
||||
status = line.strip().split('|')[-1].split(':')[-1].strip()
|
||||
|
||||
if status == '200':
|
||||
successfull_reguest+=1
|
||||
|
||||
if total_reguest == 0:
|
||||
return 0.0
|
||||
|
||||
result=(successfull_reguest / total_reguest)*100
|
||||
return round(result,1)
|
||||
except FileNotFoundError:
|
||||
return f'Файл не найден'
|
||||
|
||||
Reference in New Issue
Block a user