SSL module is not available
The problem is that Anaconda Python ships with its own SSL libraries and does not use the system SSL libraries when compiling the Python ssl module. The mod_ssl module in Apache is using the system libraries.
<--------->
The only solution is to use the system Python version and not Anaconda Python
Unless you have a specific requirement, is better to use the system Python version and not Anaconda Python.
import math
def is_smooth(my_list: list):
my_list_max_index = len(my_list) - 1
a = my_list[math.ceil(my_list_max_index / 2)]
b = my_list[math.floor(my_list_max_index / 2)]
if a == my_list[0] and b == my_list[my_list_max_index]:
return True
if a + b == my_list[0] and a + b == my_list[my_list_max_index]:
return True
return False
Почему в двумерном массиве каждый подмассив становится копией другого
Assignment statements in Python do not copy objects, they create bindings between a target and an object. For collections that are mutable or contain mutable items, a copy is sometimes needed so one can change one copy without changing the other. This module provides generic shallow and deep copy operations (explained below).
new_list = old_list.copy()
# или
new_list = old_list[:]
import copy
new_list = copy.deepcopy(old_list)
Как отключить проверку SSL в телеграмм боте?
import pandas as pd
import matplotlib.pyplot as plt
data_file = 'gapminder-FiveYearData.csv'
gapminder = pd.read_csv(data_file)
gapminder.head(n=3)
gapminder['lifeExp'].hist(bins=100)
plt.show()
import numpy as np
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt
x = [21,22,23,4,5,6,77,8,9,10,31,32,33,34,35,36,37,18,49,50,100]
num_bins = 5
n, bins, patches = plt.hist(x, num_bins, facecolor='blue', alpha=0.5)
plt.show()
from Tkinter import *
master = Tk()
def callback():
print "click!"
b = Button(master, text="OK", command=callback)
b.pack()
mainloop()
root.configure(background='black')
import tkinter as tk
from tkinter import *
стоит задача создать приложения для компьютера, которое отправляет посты во вконтакте, и при отправке каждого поста у юзера обновляется значение в базе данных на единицу.то зачем
создать api и работать с ним через код программы
closeEvent(self, event)
в MessageClosed_ExempleWindow()
?ExempleWindow- спасибо, поржал.
у меня есть бот в telegram для скачивания данных с virustotal
как можно реализовать следуюшее : Я в программе пишу /download "ссылка" после чего она идет боту в telegram . Далее у меня скачивается "файл" который отправил данный бот .
У меня есть данный бот и иммеет эту функцию . Просто я хочу зделать что бы можно было через программу это все делать не включая телегу.
Можно по точнее?
tb.send_document(chat_id, "FILEID")
import telebot
TOKEN = 'YOUR BOT TOKEN'
CHAT_ID = 'YOUR CHAT ID'
bot = telebot.TeleBot(TOKEN)
ret_msg = bot.send_voice(CHAT_ID, open('tests/test_data/record.ogg', 'rb'))
file_info = bot.get_file(ret_msg.voice.file_id)
downloaded_file = bot.download_file(file_info.file_path)
with open('new_file.ogg', 'wb') as new_file:
new_file.write(downloaded_file)
bot.delete_message(chat_id=message.chat_id,
message_id=message.message_id,
*args,
**kwargs)
import os
import logging
from pathlib import Path
from functools import wraps
from dotenv import load_dotenv
from utils import Video, BadLink
from telegram import InlineKeyboardMarkup, ChatAction
from telegram.ext import Updater, CallbackQueryHandler, MessageHandler, Filters
env_path = Path('.') / '.env'
load_dotenv(dotenv_path=env_path)
def send_action(action):
def decorator(func):
@wraps(func)
def command_func(update, context, *args, **kwargs):
context.bot.send_chat_action(chat_id=update.effective_message.chat_id, action=action)
return func(update, context, *args, **kwargs)
return command_func
return decorator
send_typing_action = send_action(ChatAction.TYPING)
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO)
logger = logging.getLogger(__name__)
@send_typing_action
def get_format(update, context):
logger.info("from {}: {}".format(update.message.chat_id, update.message.text))
try:
video = Video(update.message.text, init_keyboard=True)
except BadLink:
update.message.reply_text("Your link is not valid")
else:
reply_markup = InlineKeyboardMarkup(video.keyboard)
update.message.reply_text('Choose format:', reply_markup=reply_markup)
@send_typing_action
def download_desired_format(update, context):
query = update.callback_query
resolution_code, link, merge_formats = query.data.split(' ', 2)
print('chat_id: ', query.message.chat_id)
print('Merge formats: ', merge_formats)
query.edit_message_text(text="Downloading")
video = Video(link)
video.download(resolution_code, merge_formats)
with video.send() as files:
for f in files:
context.bot.send_document(chat_id=query.message.chat_id, document=open(f, 'rb'))
updater = Updater(token=os.getenv("TG_BOT_TOKEN"), use_context=True)
updater.dispatcher.add_handler(MessageHandler(Filters.text, get_format))
updater.dispatcher.add_handler(CallbackQueryHandler(download_desired_format))
updater.start_polling()
updater.idle()
$ python3.7 -c 'from time import clock; clock()'
-c:1: DeprecationWarning: time.clock has been deprecated in Python 3.3 and will be removed from Python 3.8: use time.perf_counter or time.process_time instead
On Windows, the equivalent activate script is in the Scripts folder:
> path\to\env\Scripts\activate
import logging
from telegram import InlineKeyboardButton, InlineKeyboardMarkup
from telegram.ext import Updater, CommandHandler, CallbackQueryHandler
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level=logging.INFO)
logger = logging.getLogger(__name__)
def start(update, context):
keyboard = [[InlineKeyboardButton("Option 1", callback_data='1'),
InlineKeyboardButton("Option 2", callback_data='2')],
[InlineKeyboardButton("Option 3", callback_data='3')]]
reply_markup = InlineKeyboardMarkup(keyboard)
update.message.reply_text('Please choose:', reply_markup=reply_markup)
def button(update, context):
query = update.callback_query
query.edit_message_text(text="Selected option: {}".format(query.data))
def help(update, context):
update.message.reply_text("Use /start to test this bot.")
def error(update, context):
"""Log Errors caused by Updates."""
logger.warning('Update "%s" caused error "%s"', update, context.error)
def main():
# Create the Updater and pass it your bot's token.
# Make sure to set use_context=True to use the new context based callbacks
# Post version 12 this will no longer be necessary
updater = Updater("TOKEN", use_context=True)
updater.dispatcher.add_handler(CommandHandler('start', start))
updater.dispatcher.add_handler(CallbackQueryHandler(button))
updater.dispatcher.add_handler(CommandHandler('help', help))
updater.dispatcher.add_error_handler(error)
# Start the Bot
updater.start_polling()
# Run the bot until the user presses Ctrl-C or the process receives SIGINT,
# SIGTERM or SIGABRT
updater.idle()
if __name__ == '__main__':
main()
Я документации не понимать