f1 = open("D:/text1.txt", 'w')
s = 'elif call.data == "f{0}": \n \
FILTER[user_id] = \'{1}\' \n \
msg = bot.send_message(call.message.chat.id, "Выбран стиль {0}.") \n \
bot.register_next_step_handler(msg, load) \n \
bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id, reply_markup = None) \n \
'
with open('D:/text1.txt', 'a') as f:
for i, value in enumerate(list[1:]):
f.write(s.format(i, value))
i = 0
with open("D:/text1.txt", "w") as f1:
while i <= 121:
val = 'elif call.data == "f{0}": \n \
FILTER[user_id] = \'{1}\' \n \
msg = bot.send_message(call.message.chat.id, "Выбран стиль {0}.") \n \
bot.register_next_step_handler(msg, load) \n \
bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id, reply_markup = None) \n \
'.format(
i, list[i + 1]
)
f1.write(val)
i += 1
import requests
import base64
with open("nums.jpeg", "rb") as image_file:
image_hash = base64.b64encode(image_file.read()).decode("utf-8")
encoded_image = 'data:image/jpeg;base64,{}'.format(image_hash)
payload = {'fileToUpload': encoded_image}
r = requests.post('http://color.photofuneditor.com/ceremony-vegas', data=payload)
if r.status_code == 200:
image_url = 'http://color.photofuneditor.com/output/{}'.format(r.json()['file_link'])
r = requests.get(image_url)
with open('new_image.jpg', 'wb') as f:
f.write(r.content)