string = "{:{fill}{align}{width}}"
print(string.format(' hello, world ', fill='=', align='^', width=50))
================== hello, world ==================
import os
columns,lines = os.get_terminal_size()
string = "{:{fill}{align}{width}}"
print(string.format(' hello, world ', fill='=', align='^', width=columns))
cur.execute("INSERT INTO data VALUES(?,?,?)", (item, ))
кроме item должны быть еще 2 параметра.list = [login,email,password1]
if password2 == password1:
for item in list:
print(item)
cur.execute("INSERT INTO data VALUES(?,?,?)", (item, ))
conn.commit()
if password2 == password1:
cur.execute("INSERT INTO data VALUES(?,?,?)", (login,email,password1,)) # Только поменять параметры местами
conn.commit()
import os
try:
with open('1.txt') as file:
data = file.read()
except FileNotFoundError as e:
print(e) # [Errno 2] No such file or directory: '1.txt'
with open('error.txt','w') as file:
file.write(str(e)) # Запишет в файл "[Errno 2] No such file or directory: '1.txt'"
# file.write(str(e.errno)) # Запишет в файл "2"
# file.write(e.strerror) # Запишет в файл "No such file or directory"
# file.write(e.filename) # Запишет в файл "1.txt"
j = json.loads(response.text) # Загружаем ответ от requests
html = j['html']['sv-product-tabs-ajax-download'] # Достаем html
soup = BeautifulSoup(html,'lxml')
# Далее все стандартно
about_product_info = soup_detail_info.find('div', class_="ty-product-feature__label")-не работает, не может найти нужные элементы.
import requests
import json
url = 'https://www.albion-online-data.com/api/v2/stats/Gold'
response = requests.get(url)
json_data = json.loads(response.text)
for data in json_data:
price = data['price']
timestamp = data['timestamp']
print(f'Дата: {timestamp} - Цена: {price}')
Дата: 2021-01-09T21:00:00 - Цена: 3007
Дата: 2021-01-09T22:00:00 - Цена: 3006
Дата: 2021-01-09T23:00:00 - Цена: 3004
Дата: 2021-01-10T00:00:00 - Цена: 3003
Много много много строк
...
...
...
...