gpt4 book ai didi

python-3.x - 从 Python 中的 HTTP 触发的 azure 函数返回 excel 文件

转载 作者:行者123 更新时间:2023-12-02 08:22:35 24 4
gpt4 key购买 nike

我正在尝试创建 Excel 并使用 Python 中的 Azure 函数返回它。 excel 已在函数内成功生成,但我不确定如何从 Azure 函数返回该 Excel。我在 C# 中找到了类似的答案

How do you return an xlsx file from an Azure function?

我无法使用类似的库将其转换为 Python。

最佳答案

可以引用这个answer ,并使用 xlrd 作为 xlsx 文件。

import logging

import azure.functions as func
import xlrd

def main(req: func.HttpRequest) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')
with xlrd.open_workbook('test.xlsx') as wb:
with wb.get_sheet(1) as sheet:
return func.HttpResponse(f"{[row for row in sheet]}")

关于python-3.x - 从 Python 中的 HTTP 触发的 azure 函数返回 excel 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67250469/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com