Answer the question
In order to leave comments, you need to log in
Write new code or tweak?
Find in the number Pi the number of the digit in the fractional part after which there is a sequence of: six 9, six 8, six 0, the first six digits, seven digits of the phone?
Write new code or fix this one
phone = "8977895" # 7-и значный номер телефона
constants = ["999999", "888888", "000000", "123456", phone]
const_max_len = max([len(constant) for constant in constants])
constants_pos = [-1]*len(constants)
size = 65536 #по сколько байт считывать за раз
pos = 0
old = ''
with open("C:\Users\Глеб\Desktop") as f:
null = f.read(1)
while True:
data = old + f.read(size)
if data == old: break
for i in range(len(constants)):
if constants_pos[i] == -1:
j = data.find(constants[i])
if j != -1: constants_pos[i] = j + pos
pos = pos + len(data) - const_max_len
old = data[-const_max_len
for (a, b) in zip(constants, constants_pos):
print(f'{a} встречается на позиции {b}')
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question