input_file = 'C:\\users\\admin\\documents\\input.txt'
with open(input_file, 'r') as file:
for line in file:
if all([raiting[-1] == '5' for raiting in line[line.index('{') + 1:line.index('}')].split(', ')]):
print(line[:line.index('=')].strip())
Ivanon = {math:4, english:4, physic:4, chemistry:4, biology:4}
Petrov = {math:4, english:5, physic:4, chemistry:5, biology:4}
Sidorov = {math:5, english:5, physic:5, chemistry:5, biology:5}
config = []
пустым и потом снова очищать, и еще несколько раз?def generate_access_config(access, ps = False):
config_all = {}
access_template = ['switchport mode access',
'switchport access vlan',
'switchport nonegotiate',
'spanning-tree portfast',
'spanning-tree bpduguard enable']
port_security = ['switchport port-security maximum 2',
'switchport port-security violation restrict',
'switchport port-security']
for intf in access:
config = []
for line in access_template:
if line.endswith('vlan') == True:
config.append('{} {}'.format(line, access[intf]))
else:
config.append(line)
if ps == True:
config.extend(port_security)
config_all[intf] = config
return(config_all)
import math
def getAmplitudesArray(array):
amplitudesArray = []
multiplier = 2
for item in array:
amplitudesArray.append(float(item * math.sqrt(multiplier)))
multiplier *= 2
return amplitudesArray
array = [1] * 10
print(getAmplitudesArray(array))
>>> [1.4142135623730951,
2.0,
2.8284271247461903,
4.0, 5.656854249492381,
8.0, 11.313708498984761,
16.0,
22.627416997969522,
32.0]
i % 3
при любом i
дает [0..2]
i % 5
при любом i
дает [0..4]
math.ceil((i % 3) / 2) * 2
дает не больше 2
math.ceil((i % 5) / 4)
дает не больше 1
3 - [0..2] - [0..1] = [0..3]
mass = [[1, {'text': 'Click', 'date': 1463565243, 'from_id': 1, 'uid': 1, 'can_edit': 1, 'cid': 1698}]]
mass[0][1]['text']
>>> 'Click'
# В переменной s будет просто строка 'CLick'
s = mass[0][1]['text']
# Либо создаем новый словарь с ключом 'text' и значением 'Click'
d = {}
d['text'] = mass[0][1]['text']
d
>>> {'text': 'Click'}