class Article(models.Model):
publications = models.ManyToManyField('Publication')
class Publication(models.Model):
...
choice_1 = (0, 0)
pip install -r requirements.txt
import re
pattern = r'Model:.*|UPC:.*'
text = '''12" Non-Stick Skillet
with Helper Handle
Model: FCT22-30HNS
UPC: 086279034182
Case Pack: 4
5½ Qt. Sauté Pan with Cover
Model: FCT33-28H
UPC: 086279034038
Case Pack: 4
8" Skillet
Model: FCT22-20
UPC: 086279034007'''
print(re.findall(pattern, text))
['Model: FCT22-30HNS ', 'UPC: 086279034182 ', 'Model: FCT33-28H ', 'UPC: 086279034038 ', 'Model: FCT22-20 ', 'UPC: 086279034007']
longpoll = VkLongPoll(vk_session)
longpoll_ = vk_api.longpoll.VkLongPoll(vk_session)
class MyList:
def __new__(cls, vars_count, *args):
for _ in range(vars_count):
yield list(*args)
a, b, c = MyList(vars_count=3)
a, b, c = (list() for _ in range(3))
def func1():
print('func1')
def func2():
print('func2')
funcs = {'1': func1, '2': func2}
func_nmbr = input('Введите, пожалуйста, номер фигуры с 1 - 4: ')
funcs[func_nmbr]()
string = 'fgfhsadsssssllfd'
counted_chars = {}
for char in string:
if char in counted_chars:
counted_chars[char] += 1
else:
counted_chars[char] = 1
print(max(counted_chars))
from collections import defaultdict
string = 'fgfhsadsssssllfd'
counted_chars = defaultdict(int)
for char in string:
counted_chars[char] += 1
print(max(counted_chars))