import logging
logging.basicConfig(filename='some_log_name.log',level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')
try:
5/0
except Exception as e:
logging.error(e)
def rand_item():
random_recipe = random.choice(parsed_recipes["items"])
name = random_recipe['name']
ingredients = random_recipe['ingredients']
howto = random_recipe['cookWay']
ready_recipe = name + ingredients + howto
return ready_recipe
from collections import Counter
my_list = [10, 10, 23, 10, 123, 66, 78, 123]
c = Counter(my_list)
>>> c
Counter({10: 3, 123: 2, 66: 1, 78: 1, 23: 1})
>>> type(c)
<class 'collections.Counter'>
d = dict(c)
>>> d
{10: 3, 123: 2, 66: 1, 78: 1, 23: 1}
>>> type(d)
<class 'dict'>
from selenium import webdriver
import selenium.webdriver.support.ui as ui
browser = webdriver.Firefox()
wait = ui.WebDriverWait(browser,30)
browser.execute_script('')#скрипт осуществлял переход на другую страницу в моем случае так в вашем по другому (driver.find_element_by_xpath("/html/body/div...]").click())
wait.until(lambda browser: browser.find_element_by_id('someID'))
some_info = browser.find_element_by_id('someID').get_attribute("outerHTML")
import shutil
import os
import sys
#читаеш аргументы командной строки
dest_folder = sys.argv[1]
count = int(sys.argv[2])
source_folder = 'you source folder'
#проверка есть ли папка
if not os.path.exists(dest_folder):
os.mkdir(dest_folder)
# listdir получить список файлов в директории
#shutil.move перенос
for name in os.listdir(source_folder)[:count]:
shutil.move(os.path.join(source_folder, name), os.path.join(dest_folder, ''))