users_list
ты его нигде не используешь. Зачем тогда он в коде?for user in users:
id = user[0]
username = user[1]
user_id = user[2]
number = user[3]
subscription = user[4]
admi = user[5]
blocked = user[6]
ban = user[7]
как правильнее записать, чтобы вывести все с тегами html
users = [
('Vasya', '12345', 'vasya@mail.ru'),
('Petr', '7654', 'Petr@mail.ru'),
('Irina', '142340385', 'irina@mail.ru'),
('Solomon', '981234125', 'solomon@mail.ru'),
]
with_markup = ' '.join(map(lambda x: f'name: {x[0]}\nid: {x[1]}\nemail: {x[2]}', users))
print(with_markup)
git clone https://github.com/alphacep/vosk-api
cd vosk-api/python/example
wget https://alphacephei.com/kaldi/models/vosk-model-small-en-us-0.15.zip
unzip vosk-model-small-en-us-0.15.zip
mv vosk-model-small-en-us-0.15 model
python3 ./test_simple.py test.wav
#!/usr/bin/env python3
from vosk import Model, KaldiRecognizer, SetLogLevel
import sys
import os
import wave
import subprocess
SetLogLevel(0)
if not os.path.exists("model"):
print ("Please download the model from https://alphacephei.com/vosk/models and unpack as 'model' in the current folder.")
exit (1)
sample_rate=16000
model = Model("model")
rec = KaldiRecognizer(model, sample_rate)
process = subprocess.Popen(['ffmpeg', '-loglevel', 'quiet', '-i',
sys.argv[1],
'-ar', str(sample_rate) , '-ac', '1', '-f', 's16le', '-'],
stdout=subprocess.PIPE)
while True:
data = process.stdout.read(4000)
if len(data) == 0:
break
if rec.AcceptWaveform(data):
print(rec.Result())
else:
print(rec.PartialResult())
print(rec.FinalResult())
import logging
logging.basicConfig(filename='example.log', encoding='utf-8', level=logging.DEBUG)
logging.debug('This message should go to the log file')
logging.info('So should this')
logging.warning('And this, too')
logging.error('And non-ASCII stuff, too, like Øresund and Malmö')
def get_names(num_items):
name_list = list()
for item in range(num_items):
name_list.append(input('Введите имя с заглавной буквы'))
return name_list
def get_quantity():
return int(input('Сколько имен надо ввести?'))
if __name__ == '__main__':
for name in get_names(get_quantity()):
if name.startswith('А'):
print('Имя', name, 'Начинается с буквы А')
message.from_user
{
"id":5786161XX,
"is_bot":false,
"first_name":"Andrew",
"username":"D.",
"last_name":"None",
"language_code":"en",
"can_join_groups":"None",
"can_read_all_group_messages":"None",
"supports_inline_queries":"None"
}
reply_to_message
@bot.message_handler(func=lambda message: True, content_types=['text'])
def command_default(m):
if m.reply_to_message:
pass
Add python 3.X to PATH
.Есть конвертер с аиограм на телебот?
sqlite3.IntegrityError: NOT NULL constraint failed: Profile.surname
Как исправить эту ошибку в pythonanywhere?
A limited account with one web app at your-username.pythonanywhere.com, restricted outbound Internet access from your apps, low CPU/bandwidth, no IPython/Jupyter notebook support.
It works and it's a great way to get started!
requests
и используем urllib.request
import json
import urllib.request
headers = {
'Content-Type': 'application/json',
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 11_4) AppleWebKit/605.1.15 '
'(KHTML, like Gecko) Version/14.1.1 Safari/605.1.15',
'Origin': 'https://yandex.ru',
'Referer': 'https://yandex.ru/',
}
API_URL = 'https://zeapi.yandex.net/lab/api/yalm/text3'
payload = {"query": "Ура Хабр", "intro": 0, "filter": 1}
params = json.dumps(payload).encode('utf8')
req = urllib.request.Request(API_URL, data=params, headers=headers)
response = urllib.request.urlopen(req)
print(response.read().decode('utf8'))
import requests
url = 'SOME_URL'
headers = {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 11_4) AppleWebKit/537.36 '
'(KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36',
'Referer': 'https://www.sex.com/'
}
response = requests.get(url, headers=headers)