python - 仅使用 Python 而不是整个 blob 检索部分 Azure 文本 blob
问题描述
这是我的应用程序用于检索 Azure 文本 blob 的 Python 函数。这是函数的文档gen_blob_to_text
(当您单击页面时,Ctrl+F 并搜索函数的名称)。
def get_text_blob(self, archive_url):
container, archive_location = paths.extract_url_elements(archive_url)
blob = None
try:
blob = self.blob_service.get_blob_to_text(container_name = container,
blob_name = archive_location)
self.logger.debug('Retrieved ' + archive_url)
except:
self.logger.error('Failed to retrieve text blob {} {}'.format(archive_url, traceback.format_exc()))
return blob
运行此函数并blob
取回对象(在我的情况下是一些 HTML 内容)后,如果我在 Visual Studio 2017 中检查它,我会得到以下不完整的 blob 文本,如...
我的问题是:如何获取全文而不是其中的一部分?我究竟做错了什么?
解决方案
我无法在我这边重现您的问题。我通过以下代码成功获取了 blob 内容:
from azure.storage.blob import (
BlockBlobService
)
accountName = "***"
accountKey = "***"
containerName = "test1"
blobService = BlockBlobService(account_name=accountName, account_key=accountKey)
blobContent = blobService.get_blob_to_text(containerName,"storage.html")
print(blobContent.content)
我尝试在Text Visualizer中对其进行调试。如果我正确拖动窗口,它可以完全显示。
希望它可以帮助你。
推荐阅读
- python - 定义一个笔记本以在每个单元格前发出隐式 %reset -fs
- postgresql - 为什么不使用索引?
- java - 在 javafx 中向我的计算器添加文本字段和标签
- graphql - Apollo 客户端:codegen 如何为@client 指令生成类型?
- android - 如何更改 ListView 中文本的颜色?
- c++ - iostream not printing to terminal in second source class (c++)
- angular - 组件调用httpget的subscribe方法后返回数据为Null
- c# - Simon Says game - Button X(随机选择)亮起时激活 Light X
- reactjs - 反应 axios 401 未经授权的 googleapis customsearch
- machine-learning - 如何制作一个类分类器来预测属于该类的概率?