import numpy as np
from itertools import zip_longest
lst = [[1, 2, 3], [4, 5, 6, 7, 8], [9, 10, 11]]
def neighbors(a, b, m=lst, r=1):
m = np.array(list(zip_longest(*m)))#.T
v = np.argwhere(m == b) - np.argwhere(m == a)
return np.abs(v).max() <= r
assert neighbors(1, 2) == True
assert neighbors(1, 6) == False
assert neighbors(5, 6) == True
assert neighbors(3, 6) == True
assert neighbors(7, 11) == True
assert neighbors(1, 9) == False
assert neighbors(7, 8) == True
path = 'D:\\For_Denis\\Projects\\nginx_log_parser\\big_log.txt'
path_1 = 'D:\\For_Denis\\Projects\\nginx_log_parser\\big_log_1.txt'
log = open(path, 'r')
logs = open(path_1, 'r')
lines = 0
for line in log:
lines = lines + 1
a = 0 #количество POST
b = 0 #количество пройденных строк
while b < lines:
check = str(logs.readline())
if 'GET' in check:
if '200' in check:
a += 1
b += 1
else:
b += 1
else:
b += 1
print(a)
path = 'D:\\For_Denis\\Projects\\nginx_log_parser\\nginx.txt'
a = 0 #количество GET
c = 0 #количество POST
b = 0 #количество пройденных строк
with open(path) as f:
for line in f:
b += 1
if 'GET' in line:
a +=1
elif 'POST' in line:
c +=1
else:
break
print(a,",", c)
import vk_api
? Также вам стоит почитать про python в целом.