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

标签 python-3.x azure python-requests azure-functions xlsxwriter

我正在尝试创建 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/

相关文章:

python - ModuleNotFoundError : No module named 'requests'

python - 从当前工作目录开始获取类的文件路径

Python包: Can I look for config/yml file from project directory which called it?

Azure 站点到多站点 VPN 部署

azure - C# Azure 存储从一个 blob 复制文件到另一个 blob

python - 通过tor发出请求,requests.exceptions.ConnectionError Errno 61 : Connection Refused

python - 请求.exceptions.SSLError : [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl. c:600)

python-3.x - 使用 livy 向 AWS EMR 提交具有虚拟环境的 pyspark 作业

python - 您可以更改 Django Admin 应用程序中的字段标签吗?

azure - 与 Azure 上托管的 Web 容器建立 https 连接