Python将列表转换为post请求的可用参数

Python将列表转换为post请求的可用参数,python,Python,我有一个URL列表: images=['https://example.co/123','https://example.co/124',...] 我需要创建另一个列表,如下所示: files=[('images',requests.get(image).content),('images',requests.get(image).content),..] 我需要一个“图像”列表,图像列表中每个图像url的requests.getimage.content。如何做到这一点?听起来像是列表理解

我有一个URL列表:

images=['https://example.co/123','https://example.co/124',...]
我需要创建另一个列表,如下所示:

files=[('images',requests.get(image).content),('images',requests.get(image).content),..]

我需要一个“图像”列表,图像列表中每个图像url的requests.getimage.content。如何做到这一点?

听起来像是列表理解的工作

images=['https://example.co/123','https://example.co/124', ...]
files = [('images', requests.get(image).content) for image in images]

令人惊叹的我从没想过会这么简单。谢谢“如果答案允许,我会接受的。”马修塞米克说,这就是我喜欢Python的原因。我从来没有想过,要想找到几乎所有句法难题的正确解决方案,反应会这么简单