def is_digit(n):
try:
int(n)
return True
except ValueError:
return False
blocks = driver.find_elements_by_xpath("//*[contains(@class, 'd-inline-block')]")
for i, block in enumerate(blocks):
with open(file=f'{i}.png', mode='wb') as f:
f.write(block.screenshot_as_png)
and i+1 <= length
print(list(set(source_list)))
source_list = [1, 4, 2, 3, 4, 5, 6]
print(source_list)
print(list(set(source_list)))
[1, 4, 2, 3, 4, 5, 6]
[1, 2, 3, 4, 5, 6]
Process finished with exit code 0
import requests
import json
content = requests.get("http://rzhunemogu.ru/RandJSON.aspx?CType=1")
response_json = json.loads(content.text.replace('\r\n', '\\r\\n'))
print(response_json)
{'content': 'Смотpишь по телевизоpу pекламу - в ней pекламиpуют жуpнал. Покупаешь жуpнал - а там pеклама магазина. Идёшь в магазин - а там пpодают телевизоpы. Покупаешь телевизоp, включаешь - а там опять pеклама того же жуpнала. Где же выход?!'}
from filelock import Timeout, FileLock
lock = FileLock("high_ground.txt.lock")
with lock:
open("high_ground.txt", "a").write("You were the chosen one.")
from pyvirtualdisplay import Display
from selenium import webdriver
display = Display(visible=0, size=(800, 600))
display.start()
driver = webdriver.Chrome()
driver.get('http://google.com/')
driver.quit()
display.stop()
from selenium import webdriver
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument(f"user-data-dir={profile_path}")
driver = webdriver.Chrome(options=chrome_options)
import csv
import json
def write_csv(data, file, encoding="utf-8"):
with open(file, "w", newline="", encoding=encoding) as f1:
fieldnames = data[0].keys()
writer = csv.DictWriter(f1, fieldnames=fieldnames)
writer.writeheader()
writer.writerows(data)
with open('type_info.json', 'r') as f:
data = json.load(f)
write_csv(data, "out.csv", encoding="utf-8")
text += "{}. {} {} - {} раз\n".format(i+1, vkGetFirstName(int(row[0])), vkGetLastName(int(row[0])), row[1])
r = int(input("Введіть кількість рядків: "))
mas = []
for i in range(r):
x = [int(j) for j in input().split()]
mas.append(x)
for i in mas:
if len(i) > 6:
print(i[0])
Введіть кількість рядків: 3
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
1
8
15
Process finished with exit code 0
from multiprocessing import Process
import time
print(1)
def func1():
print('test1')
time.sleep(10)
def func2():
print('test2')
time.sleep(5)
def test_multiprocessing():
p_func1 = Process(target=func1)
p_func2 = Process(target=func2)
p_func1.start()
p_func2.start()
p_func1.join()
p_func2.join()
print('done')
if __name__ == '__main__':
test_multiprocessing()
1
11
test2
test1
done
Process finished with exit code 0
if 'некоторые слова' in html:
print('Некоторые слова есть в HTML')
else:
print('Некоторых слов нет в HTML)
@daily rm -rf /tmp/.org.chromium.Chromium*
# Sleep before starting new loop
print ('Set pausa time')
for i in range(900, 0, -1):
sys.stdout.write(str(i) + ' ')
sys.stdout.flush()
time.sleep(1)