def get_bb_id(parcel):
return connect(table='parcels',
field='document_id',
equally=parcel,
item='big_bag_id')
order_with_big_bags = {get_bb_id(parcel): [parcel] for parcel in orders}
print(order_with_big_bags)
enumerate
и i
добавлены т.к. я прохожусь по листам.orders = ['28-1661-0907', '28-1661-0896', '28-1661-0885', '28-1661-0874', '28-1661-0863', '28-1661-0852',
'28-1661-0841', '28-1661-0830', '28-1661-0808', '28-1661-0797', '28-1661-0786', '28-1661-0775',
'28-1661-0764', '28-1661-0753']
bb_ids = [4321, 4320, 4319, 4318, 4317, 4316, 4315, 4314, 4313, 4312, 4311, 4310, 4309, 4308]
order_with_big_bags = {}
for i, parcel in enumerate(orders):
bb_id = bb_ids[i]
try:
if isinstance(order_with_big_bags[bb_id], list):
order_with_big_bags[bb_id].append(parcel)
except KeyError:
order_with_big_bags[bb_id] = [parcel]
print(order_with_big_bags)
order_with_big_bags
, который объявлен в теле цикла, естественно вам вернет последнее значение. Объявите перед циклом '<a href="tg://user?id= + msg.chat.id + ">msg.chat.first_name</a>'
msg.from.id
, msg.from.first_name
aiogram > bot > base.py
в функции get_new_session
в ClientSession добавить trust_env=True
aiogram > bot > api.py
в функции make_request
в запросе установить ssl = False
def generate_file_payload(exclude=None, **kwargs):
"""
Generate payload
:param exclude:
:param kwargs:
:return: dict
"""
if exclude is None:
exclude = ['file_path']
data = FormData()
for key, value in kwargs.items():
if key not in exclude + DEFAULT_FILTER and value is not None and not key.startswith('_'):
data.add_field(''.join([key.split('_')[0].lower(), *map(str.title, key.split('_')[1:])]), str(value))
if key == 'file_path':
file_path = str(value).replace('\\', '/')
data.add_field('uploadFile',
open(str(value), 'rb'),
filename=file_path.split('/')[-1], content_type='multipart/form-data')
return data
final += chr(summa % 32 + 1040)