【发布时间】:2015-11-26 09:49:08
【问题描述】:
我想根据要求发送一张图片(通过 URL 或路径)。 我使用源code here. 该代码已经有一个发送图像的示例(通过 URL 或路径),但我不明白,因为我是 Python 新手。
这里是示例代码sn-p:
elif text == '/image': #request
img = Image.new('RGB', (512, 512))
base = random.randint(0, 16777216)
pixels = [base+i*j for i in range(512) for j in range(512)] # generate sample image
img.putdata(pixels)
output = StringIO.StringIO()
img.save(output, 'JPEG')
reply(img=output.getvalue())
一些API信息可以是found here.
感谢您的耐心等待。
【问题讨论】:
-
请在此处查看我的答案:stackoverflow.com/a/32441772/1097372 我也是 python 新手,所以也许有人可以在那里改进我的代码。
标签: python image api telegram-bot