где на стороне сервера, будет информация о том, что находится ли фильм в избранном,
# site_base.txt
https://xakep.ru
https://habr.com
https://vc.ru
# [file_name].py
import requests
import os
def append_filename(url:str, filename:str) ->tuple:
domain = url.split('//')[-1]
data = (domain, url + '/' + filename)
return data
def save_file_to_disk(filename:str):
if not os.path.exists('files'): os.mkdir('files')
with open('site_base.txt', 'r', encoding='UTF-8') as site_base:
sites_list = site_base.read().split('\n')
urls_list = [append_filename(url, filename) for url in sites_list]
for url in urls_list:
try:
domain = url[0]
requested_url = url[1]
response = requests.get(requested_url)
saved_filename = domain+'_'+filename
file_path = os.path.join('files',saved_filename)
with open(file_path, 'a', encoding='UTF-8') as robots:
robots.write(response.text)
except requests.exceptions.RequestException as e:
print(e)
save_file_to_disk('robots.txt')
save_file_to_disk('sitemap.xml')
goods_dict = [
{'id': '1', 'goods': 'macbook 16 pro', 'brand': 'Apple'},
{'id': '2', 'goods': 'ThinkPad X1 Extreme Gen 3', 'brand': 'lenovo'},
{'id': '3', 'goods': 'XPS 17 9710 Silver', 'brand': 'Dell'}
]
#лист акссесуаров
add_lists = [
['Apple','стилус'],
['lenovo','коврик'],
['hp','мышь'],
['asus','флешка']
]
for item in add_lists:
item_brand = item[0]
item_name = item[1]
print(item_brand)
print('-',item_name)
for good in goods_dict:
good_brand = good['brand']
print('--',good_brand)
if not good.get('accessory'):
if good_brand == item_brand:
good['accessory'] = item_name
else:
good['accessory'] = None
for good in goods_dict:
print(good)
sqlite3.IntegrityError: UNIQUE constraint failed: test.us_id.
sqlite3.IntegrityError: условие "УНИКАЛЬНОЕ значение" не соблюдено: test.us_id.
some_dict = {}
some_dict["letter"] = db_row[0] # db_row - кортеж
...
return some_dict
some_dict = {}
... # do cycle
some_dict[cha_index] = cha[cha_index] # cha_index - индекс значения в списке.
Или отправьте на фриланс где не дорого за задачу возьмут. на кворке желающих не нашлось (
urlpatterns = [
path('<int:cocktail_id>/', by_cocktail_id),
path('<str:cocktail_name>/', by_cocktail_name),
path('', index),
]
имя%20коктейля
call.message.text
не может быть преобразовано в число.def generator():
pass
gen = generator()
gen = (s(k)/4 for k in range(10)):
print(next(gen))
с отступом.def generator():
pass
gen = generator()
for _ in range(10):
print(next(gen))