python 我怎样才能在flask的变量中只得到一个图像的名称?

3duebb1j  于 2023-01-16  发布在  Python
关注(0)|答案(1)|浏览(88)
def upload_image():  # put application's code here
    if request.method == "POST":
        image = request.files.get('file', '')
        print(image)

我想在变量中获取名称“new.jpg”,但却得到了
〈文件存储:'新. jpg'('图像/jpeg')〉作为输出

nzk0hqpo

nzk0hqpo1#

您可以使用filename属性:

def upload_image():
    if request.method == "POST":
        image = request.files.get('file', '')
        image_name = image.filename
        print(image_name)

相关问题