if callback.data in ('test1', 'test2', 'test3'):
for ret in cur.execute("SELECT id, title, score FROM names WHERE name = ?", (callback.data, )):
await bot.send_video(callback.from_user.id, ret[0], caption=f'Текст под постом1: {ret[1]}\n Текст под постом2: {ret[-1]}\n\n Текст под постом3 \n\nТекст под постом4, reply_markup=underpost_butt)
Fetches the next row of a query result set, returning a single sequence, or None when no more data is available.
print("\u0417\u0430\u043c\u0448\u0435\u0432\u0456 \u043c\u044e\u043b\u0456")
чтобы убедиться, что строка в норме. Машина её прочитает без проблем.json_ensure_ascii=False
в секцию "formatter_json". import typing as t
def transform(inp: str) -> str:
return inp # тут твоё преобразование строк
def change_list(lst: t.List[t.Any]) -> t.List[t.Any]:
result: t.List[t.Any] = []
for item in lst:
if isinstance(item, str):
result.append(transform(item))
elif isinstance(item, list):
result.append(change_list(item))
elif isinstance(item, dict):
result.append(change_dict(item))
else:
result.append(item)
return result
def change_dict(dct: t.Dict[str, t.Any]) -> t.Dict[str, t.Any]:
result: t.Dict[str, t.Any] = {}
for k, v in dct.items():
if isinstance(v, str):
result[k] = transform(v)
elif isintance(v, dict):
result[k] = change_dict(v)
elif isinstance(v, list): # что делать со списками, если они будут?
result[k] = change_list(v)
else:
result[k] = v
return result
Use our solutions to build and connect bots to interact with your users. Use Viber’s API to connect a bot, or team up with a trusted partner to develop the solution that suits you.
Check our NodeJS sample to see Viber bot in action
line = input()
last = None
counter = 0
for ch in line:
if ch != last:
if last is not None:
print(counter, end='')
counter = 1
last = ch
print(ch, end='')
else:
counter += 1
if last is not None:
print(counter, end='')