driver.findElementsByClassName("className");
driver.findElementsByCssSelector(".className");
driver.findElementsById("elementId");
driver.findElementsByLinkText("linkText");
driver.findElementsByName("elementName");
driver.findElementsByPartialLinkText("partialText");
driver.findElementsByTagName("elementTagName");
driver.findElementsByXPath("xPath");
driver.findElements(By.className("className"));
driver.findElements(By.cssSelector(".className"));
driver.findElements(By.id("elementId"));
driver.findElements(By.linkText("linkText"));
driver.findElements(By.name("elementName"));
driver.findElements(By.partialLinkText("partialText"));
driver.findElements(By.tagName("elementTagName"));
driver.findElements(By.xpath("xPath"));
from selenium.webdriver.common.by import By
driver.find_element(By.XPATH, xpath)
Из-за чего это может быть
, и как это возможно решить?
from PIL import Image
im = Image.open("source.png").convert('RGBA')
im = im.resize((100, 100), resample=Image.NEAREST)
im.save("result.png")
$ echo -e "1,2\n3,4" | clickhouse-local --query "
CREATE TABLE table (a Int64, b Int64) ENGINE = File(CSV, stdin);
SELECT a, b FROM table;
DROP TABLE table"
Read 2 rows, 32.00 B in 0.000 sec., 4987 rows/sec., 77.93 KiB/sec.
1 2
3 4
import sqlite3
def dict_factory(cursor, row):
d = {}
for idx, col in enumerate(cursor.description):
d[col[0]] = row[idx]
return d
con = sqlite3.connect(":memory:")
con.row_factory = dict_factory
cur = con.cursor()
cur.execute("select 1 as a")
print cur.fetchone()["a"]
import fdb
con = fdb.connect(dsn='127.0.0.1:/firebird/data/test.db',
port=3050,
user='test_user',
password='76d8bf4f81598b847170')
cur = con.cursor()
cur.execute("select * from NEWTABLE order by NAME")
def dict_cursor(cursor):
column_names = [x[0] for x in cursor.description]
for row in cursor:
yield {key: value for key, value in zip(column_names, row)}
for item in dict_cursor(cur):
print(item)
{'NAME': 'Ivan', 'SURNAME': 'Ivanov'}
{'NAME': 'Petr', 'SURNAME': 'Petrov'}
даже Pillow-SIMD не даёт заметного выигрыша
$ pip uninstall pillow
$ CC="cc -mavx2" pip install -U --force-reinstall pillow-simd
im.save('png.png', compress_level=1)
import requests
proxies = {
'http': 'http://10.10.1.10:3128',
'https': 'http://10.10.1.10:1080',
}
requests.get('http://example.org', proxies=proxies)
Какими командами сделать трункейт данных и оставить данные за последний год?
TRUNCATE TABLE PartitionTable1
WITH (PARTITIONS (2, 4, 6 TO 8));
GO
DELETE FROM table WHERE date <= %date%
DELETE TOP (1000) FROM table WHERE date <= %date%
Какими командами проверить на целостьность и оптимизировать?
# Xpath надо написать самому
iframe = driver.find_element_by_xpath("//iframe")
driver.switch_to.frame(iframe)
driver.switch_to.default_content()
import requests
params = {
'name': 'Иванов Иван Иванович',
'numberOrInn': '1111111111',
}
response = requests.get('https://www.rgs.ru/api/agents/checkAgent', params=params)
# {"Status":"NotFound","ErrorCorrelationIds":[],"ErrorCode":null}
print(response.text)
Naive 13.342852999999998 seconds
Optimized 0.22429799999999744 seconds
Unique: [ True] Counts: [25000000]
import time
from time import process_time
import numpy
matrix = []
def naive():
from time import process_time
def create_matrix(n):
res_list = []
for i_ind in range(n):
res_list.append(list())
for j_ind in range(n):
res_list[i_ind].append(0)
return res_list
def get_counting_func(q_vector, v_vector):
q_matrix = [[*q_vector] for i in range(len(q_vector))]
v_matrix = [[i for j in range(len(v_vector))] for i in v_vector]
def t_func(i_start, i_len, j_start, j_len):
global matrix
for i in range(i_start, i_start + i_len):
for j in range(j_start, j_start + j_len):
matrix[i][j] = ((q_matrix[i][j]) ** 2 + (v_matrix[i][j]) ** 2) ** 0.5
return t_func
n_el = 5000
global matrix
matrix = create_matrix(n_el)
q_vect = [(i + 11) ** 2 for i in range(n_el)]
p_vect = [(i * 3 + 13) * 17 for i in range(n_el)]
counting_func = get_counting_func(q_vect, p_vect)
start_time = process_time()
counting_func(0, n_el, 0, n_el)
print('Naive ', process_time() - start_time, "seconds")
return matrix
def optimized():
start_time = process_time()
n_el = 5000
res = numpy.fromfunction(lambda i, j: (((i * 3 + 13) * 17) ** 2 + (j + 11) ** 4) ** 0.5, (n_el, n_el)
, dtype=numpy.float32)
print('Optimized ', process_time() - start_time, "seconds")
return res
if __name__ == '__main__':
first = naive()
second = optimized()
unique, counts = numpy.unique(numpy.isclose(second, numpy.array(first)), return_counts=True)
print(f'Unique: {unique} Counts: {counts}')
int(lvl) >= int(1)
lvl = int(await get_lvl(message))
if 0 <= lvl <= 9:
cost = 5000
elif 10 <= lvl <= 19:
cost = 10000
...
lvl = 23
costs = {
10: 5000,
20: 10000,
}
rounded_lvl = (lvl // 10) * 10
print(f'Rounded level: {rounded_lvl}')
cost = costs.get(rounded_lvl)
print(f'Cost: {cost}')
Rounded level: 20
Cost: 10000
Process finished with exit code 0