import base64
import requests
with open("fig1.png", "rb") as file:
url = "https://api.imgbb.com/1/upload"
# key_imgbb - это твой api ключ, получаешь его зарегавшись на сервисе
payload = {
"key": key_imgbb,
"image": base64.b64encode(file.read()),
}
res = requests.post(url, payload)
print(res.json()) # забираешь отсюда нужную тебе ссылку на файл, и отправляешь в google
from itertools import product
tuple_one = ('one', 'two', 'thousand') # name
tuple_two = ('blue', 'black', 'yellow') # color
print(list(product(tuple_one, tuple_two)))
[('one', 'blue'), ('one', 'black'), ('one', 'yellow'), ('two', 'blue'), ('two', 'black'), ('two', 'yellow'), ('thousand', 'blue'), ('thousand', 'black'), ('thousand', 'yellow')]
for line in allurl:
writers.writerows(line)
writers.writerows(allurl)
max_number = float('-inf')
[(max_number := i) for i in map(int, input().split(',')) if i > max_number]
x = int(input('введите первое значение и второе значение через пробел и запятую:'))
from itertools import product
print(list(product('1234567890', repeat=3)))
from collections import Counter
lib = Counter(input('Введите слово:\n'))
from itertools import combinations
sq = {e**2: e for e in range(1, 5001)}
maximum = 0
cmaximum = 0
count = 0
for a, b in combinations(sq, 2):
ab = a + b
if ab in sq:
count += 1
tmp_maximum = sq[a] + sq[b] + sq[ab]
cmaximum, maximum = (sq[ab], tmp_maximum) if tmp_maximum > maximum else (cmaximum, maximum)
print(count, cmaximum)
def get_without_first_and_last(numbers):
return sorted([int(str(x)[1:-1]) for x in numbers if len(str(x)) > 2])
my_data = [13, 442, 23, 1234, 5]
print(get_without_first_and_last(my_data))
def save_doc(items, path):
with open(path, "w", newline='') as file:
writer = csv.writer(file, delimiter=';')
writer.writerow()
writer.writerow(['Термопаста', 'Цена'])
for item in items:
writer.writerow([item['title'], item['brand']])
class Article(models.Model):
publications = models.ManyToManyField('Publication')
class Publication(models.Model):
...
choice_1 = (0, 0)
pip install -r requirements.txt
import re
pattern = r'Model:.*|UPC:.*'
text = '''12" Non-Stick Skillet
with Helper Handle
Model: FCT22-30HNS
UPC: 086279034182
Case Pack: 4
5½ Qt. Sauté Pan with Cover
Model: FCT33-28H
UPC: 086279034038
Case Pack: 4
8" Skillet
Model: FCT22-20
UPC: 086279034007'''
print(re.findall(pattern, text))
['Model: FCT22-30HNS ', 'UPC: 086279034182 ', 'Model: FCT33-28H ', 'UPC: 086279034038 ', 'Model: FCT22-20 ', 'UPC: 086279034007']