python - 如何使用 Python 访问 Azure 中的队列消息?

标签 python azure azure-storage azure-queues azure-storage-queues

我想在我的 python 代码中访问队列中的一些数据。

我正在使用以下代码:

from azure.storage.queue import QueueService

queue_service = QueueService(account_name='', account_key='')

messages = queue_service.get_messages('queue', num_messages=5)

for message in messages:
    print(message.id)
    print(message.content)

但是内容的输出是以某种编码消息的形式。

如何解码?

最佳答案

您可以使用print(base64.b64decode(message.content))

from azure.storage.queue import QueueService
import base64

queue_service = QueueService(account_name='', account_key='')

messages = queue_service.get_messages('queue', num_messages=5)

for message in messages:
    print(message.id)
    print(message.content)
    print(base64.b64decode(message.content))

enter image description here

关于python - 如何使用 Python 访问 Azure 中的队列消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57248675/

相关文章:

azure - 如何在powershell中循环遍历2个数组?

postgresql - 如何使用用户名和密码从 Azure AD 检索到的 token 对 Azure PostgreSQL 进行身份验证?

node.js - Azure blob sasToken "Signature did not match"

azure - 无法访问 Pulumi 创建的 Azure 存储表 - 访问被禁止 (403)

python - 将函数绑定(bind)到 Kivy 按钮

python - 属性错误: module 'tensorflow.contrib.slim' has no attribute 'model_analyzer'

python - 如何使用 Insert/Modify/Remove 将 dynamodb 设计为 Elastic search

azure - 使用 Azure CLI 将文件夹从 PC 上传到存储帐户容器

Azure 存储导出作业失败,错误代码为 ResourceNotFound

python - 如何使用 Python 将元组的元组写入 CSV 文件