yf.download(tickers = nasdaq_tickers, period = 'max', interval = '1d', group_by = 'ticker', threads=False)
yf.download(tickers = nasdaq_tickers, period = 'max', interval = '1d', group_by = 'ticker', threads=10)
import os
import psycopg2
DATABASE_URL = os.environ['DATABASE_URL']
conn = psycopg2.connect(DATABASE_URL, sslmode='require')
first = []
second = []
first.append(1)
print(f'1) First: {first} Second: {second} ')
second = first
print(f'2) First: {first} Second: {second} ')<code></code>
first.append(2)
print(f'3) First: {first} Second: {second} ')
1) First: [1] Second: []
2) First: [1] Second: [1]
3) First: [1, 2] Second: [1, 2]
Process finished with exit code 0
first = []
second = []
first.append(1)
print(f'1) First: {first} Second: {second} ')
second = first[:]
print(f'2) First: {first} Second: {second} ')
first.append(2)
print(f'3) First: {first} Second: {second} ')
1) First: [1] Second: []
2) First: [1] Second: [1]
3) First: [1, 2] Second: [1]
Process finished with exit code 0
//*[@role='most_interest']//a[contains(text(), 'изнутри') or contains(text(), 'нативного')]
import json
result = [1, 2, 3, 'Тестовый текст']
with open('result.json', 'w', encoding='utf8') as f:
json.dump(result, f, ensure_ascii=False)
https://pentaschool.ru/trainer/p/4
page = 1
test = f'test/page/{page}'
import csv
from collections import defaultdict
result = defaultdict(int)
with open('1.csv') as f:
reader = csv.DictReader(f)
for row in reader:
full_address_tuple =(row['town'], row['street'], )
result[full_address_tuple] += 1
for key, value in result.items():
print(key, ' - ', value)
('town1', 'street1') - 1
('town1', 'street2') - 2
('town2', 'street2') - 1
('town2', 'street1') - 1
town,street
town1,street1
town1,street2
town1,street2
town2,street2
town2,street1
class A:
def __init__(self):
super().__init__()
self.aa = 2
class B:
def __init__(self):
super().__init__()
self.ab = 3
class C(A, B):
pass
c = C()
print(c.aa, c.ab)
(//p[@class='message-text'])[last()]
# Click the link to activate the alert
driver.find_element(By.LINK_TEXT, "See a sample confirm").click()
# Wait for the alert to be displayed
wait.until(expected_conditions.alert_is_present())
# Store the alert in a variable for reuse
alert = driver.switch_to.alert
# Store the alert text in a variable
text = alert.text
# Press the Cancel button
alert.dismiss()
YUhSMGNITTZMeTl6TWpBeU1DMHdOUzVoYm1SeWIyVmxaQzV5ZFM5bWFXeGxjeTh5TURJeEx6RXlMekkzTDNSeVlXWm1hV05qYjNBelpDMHhOalF3TlRZNU9UZ3hMWGQzZHk1aGJtUnliMlZsWkM1eWRTNWhjR3M9fDE2NDExMzg0MjN8MzA=
aHR0cHM6Ly9zMjAyMC0wNS5hbmRyb2VlZC5ydS9maWxlcy8yMDIxLzEyLzI3L3RyYWZmaWNjb3AzZC0xNjQwNTY5OTgxLXd3dy5hbmRyb2VlZC5ydS5hcGs=|1641138423|30
https://s2020-05.androeed.ru/files/2021/12/27/trafficcop3d-1640569981-www.androeed.ru.apk
from more_itertools import windowed
import datetime
import statistics
dates = [
datetime.datetime(year=2021, month=12, day=20, hour=16, minute=54, second=56),
datetime.datetime(year=2021, month=12, day=20, hour=16, minute=54, second=57),
datetime.datetime(year=2021, month=12, day=20, hour=16, minute=54, second=57),
]
diffs = []
for first, second in windowed(dates, 2):
diffs.append((second-first).total_seconds())
print(f'Avg: {statistics.mean(diffs)}')
Avg: 0.5
Process finished with exit code 0
from selenium.webdriver.common.by import By
element = driver.find_element(By.XPATH, xpath)
conn = psycopg2.connect(DSN)
with conn:
with conn.cursor() as curs:
curs.execute(SQL1)
conn.close()
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")
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)