简体   繁体   中英

Python - How to set files to list of tuples

Im new to python. How to set files to list of tuples in following format?

multiple_files = [
     ('file', ('foo.png', file.read())),
     ('file', ('bar.png', file.read())]

Python code:

from flask import request
multiple_files = []
inspect_files = request.files.getlist('file')
print(inspect_files) # [<FileStorage: 'foo.png' ('image/png')>, <FileStorage: 'bar.png' ('image/png')>]
for file in inspect_files:
    #What is the logic to set files from inspect_files to list of tuples and push it into multiples_files?

before print add

multiple_files.push(inspect_files )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM