def KeyLen(d1):
d2=d1.copy() #надо копировать один объект (словарь) в другой, т.к. если присвоить через =, то при измененении первого будет меняться и второй
for k1 in d1.keys():
k2=k1+str(len(k1))
d2[k2]=d1[k1]
del d2[k1]
return (d2)
k1 = {"a_1":111, "a_2":104, "a_3":107, "a_4":90, "a_5":115, "a_6":107, "a_7":106, "a_8":107, "a_9":95, "a_10":116, "a_11":127, "a_12":115, "a_13":102, "a_14":99}
k2 = {"b_1":113, "b_2":107, "b_3":123, "b_4":122, "b_5":117, "b_6":112, "b_7":105, "b_8":108, "b_9":111, "b_10":114, "b_11":102, "b_12":104}
general_row = dict(sorted({**k1, **k2}.items(), key=lambda x: x[1]))
general_row_copy = general_row.copy()
k = 1
for key in general_row_copy:
general_row_copy[key] = k
k += 1
counter = 1
sum_of_rank = 0
listValues=list ( general_row.values() )
uniqValuesDictDup={x:listValues.count(x) for x in listValues
if listValues.count(x)>1}
for i in uniqValuesDictDup:
#ключи исходного словаря [с дублями]
t=[x for x in general_row if general_row[x]==i]
#ключи-порядковые номера-ранги второго словаря
k=[general_row_copy[x] for x in general_row_copy if x in t]
av= sum(k)/len(t)
print (t,k, 'среднее=',av)
for j in t:
general_row_copy[j]=sum(k)/len(t)
for i in sorted(general_row_copy):
print (i, general_row_copy[i], '\r')
cur.execute('...select .... from ?', (d['ru']))
#!/usr/bin/env python
# pylint: disable=E0611,E0213,E1102,E1101,R0913,R0904
#
# A library that provides a Python interface to the Telegram Bot API
# Copyright (C) 2015-2022
# Leandro Toledo de Souza <devs@python-telegram-bot.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser Public License for more details.
#
# You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""This module contains an object that represents a Telegram Bot."""
import functools
import logging
import warnings
from datetime import datetime
from typing import (
TYPE_CHECKING,
Callable,
List,
Optional,
Tuple,
TypeVar,
Union,
no_type_check,
Dict,
cast,
Sequence,
)
try:
import ujson as json
except ImportError:
import json # type: ignore[no-redef] # noqa: F723
try:
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import serialization
CRYPTO_INSTALLED = True
except ImportError:
default_backend = None # type: ignore[assignment]
serialization = None # type: ignore[assignment]
CRYPTO_INSTALLED = False
from telegram import (
Animation,
Audio,
i=[i.find_element_by_tag_name('a').get_attribute('href')[26:-1] for i in all_urls]
i=[x[26:-1] for x in i]
list (some_list[0].keys() )
[(i, list(some_list[i].keys())[0]) for i in some_list]
import os
from os import walk
dir1='xxxxxxxxx'
f = [] #список куды будут добавляться имена файлов из dir1
for (dirpath, dirnames, filenames) in walk(dir1): #dirpath - путь к директории, не нужен, dirnames - имена вложенных директорий, не нужны, filenames - имена файлов
f.extend(filenames)
break
print (f)
df1=pandas.read_excel(путь, header=0)
print (df1.loc[df1['Боец']=='антон'])
List=df1.to_numpy().tolist()
student = ["Вася", "Петя", "Ваня", "Света"]
s1=s=['(print (\"Все студенты на месте. Начинаем занятие!\")) if ( "'] +['" and "'.join(student)]+['\" in student) else ( print (\"Отсутствующие к экзамену допущены не будут\"))']
s2=''.join(s1)
eval(s2)
p1.loc[p1['height]==p1['height'].max()]['name']
p1.loc[p1['height]==p1['height'].max()]['name'].tolist()
p1.loc[p1['height]==p1['height'].max()]['name'].values
, если, например, известно, что нужно взять только первое ..values[0]. Если, конечно, известно, что оно будет существовать cur = con.cursor()
sql = 'INSERT INTO base_url(url, name) VALUES("{}", "url")'.format(element) # здесь element является url адресом, а url это просто обозначение для второго столбца name
print (sql)
cur.execute(sql)
con.commit()
con.close()