import xlwt
book = xlwt.Workbook()
sheet1 = book.add_sheet("Sheet1")
# твои данные для занесения в Excel
data = [
['player1', 'win', '101'],
['player2', 'lose', '102']]
for row_index, row in enumerate(data):
for col_index, value in enumerate(row):
sheet1.write(row_index, col_index, value)
book.save("test.xls")
if any(all(cell in ocells for cell in combo) for combo in win_combos):
# есть совпадение комбинации нулей
oset = set(ocells)
if any(not(set(combo)-oset) for combo in win_combos):
{'Интендификатор мастера': 0, '654': [1, 3, 4], '2425': 2, '—': [5, 6, 7, 8, 9, 10]}
{'Интендификатор мастера': [0], '654': [1, 3, 4], '2425': 2, '—': [5, 6, 7, 8, 9, 10]}
a = ['p', 'p', 'p', 'p', 'p', 'p', 'figure', 'h2', 'figure', 'p', 'p', 'p', 'p', 'p', 'p']
patt = ['p', 'figure', 'h2', 'figure']
if any(a[i:i+len(patt)] == patt for i in range(len(a)-len(patt))):
print('found')
# coding:utf-8
return words
text = base_work.all_id()
bot.send_message(message.chat.id, 'В течении 3 секунд, отправиться всем пользователям!')
for i, *_ in text:
@bot.callback_query_handler(func=lambda call:True)
def call_handler(call):
if call.data == "first":
bot.send_message(call.message.chat.id, text="Введите свой вопрос")
elif call.data == "sec":
bot.send_message(call.message.chat.id, text="Пришлите свои варианты ответа в столбик")
@bot.callback_query_handler(func=lambda call:True)
def call_handler(call):
if call.data == "first":
call_opros(call)
elif call.data == "sec":
call_answer(call)
def call_opros(call):
bot.send_message(call.message.chat.id, text="Введите свой вопрос")
def call_answer(call):
bot.send_message(call.message.chat.id, text="Пришлите свои варианты ответа в столбик")
new_news = []
soup = BeautifulSoup(page.text, "html.parser")
news = soup.findAll('a', class_='news-item')
for i in range(len(news)):
if news[i].find('span', class_='title') is not None:
new_news.append(f"{news[i]['href']} {news[i].text}")
bot.send_message(message.chat.id, ('\n'.join(new_news[:5])))
for i in range(len(news)):
news[i]['href']
использовать
for item in news:
item['href']
new_news = []
soup = BeautifulSoup(page.text, "html.parser")
news = soup.findAll('a', class_='news-item')
for i in range(len(news)):
print('ссылка', news[i]['href']) # здесь находится ссылка на соответствующую новость.
if news[i].find('span', class_='title') is not None:
new_news.append(news[i].text)
requests.compat.urljoin('https://news.am', news[i]['href']))
[{'coordinates': {'latitude': '37.0902', 'longitude': '-95.7129'},
'country': 'US',
'country_code': 'US',
'country_population': 310232863,
'id': 225,
'last_updated': '2020-04-15T18:00:46.171813Z',
'latest': {'confirmed': 607670, 'deaths': 25832, 'recovered': 0},
'province': ''}]
location['confirmed']
, а location[0]['latest']['confirmed']
ну и другие аналогично. grouped = # массив суммированных значений из предыдущего кода
grouped.sort(key=lambda x: x['score'], reverse=True)
или дополнить следующим образом, чтобы сортировал по id в случае одинаковых score
grouped.sort(key=lambda x: (x['score'], x['id']), reverse=True)