gpt4 book ai didi

python - azure Blob : upload directory content using a loop in Python

转载 作者:太空宇宙 更新时间:2023-11-03 16:39:36 33 4
gpt4 key购买 nike

我想使用循环将一些文件上传到 blob 容器。即文件 xaa,xab,xac

我尝试了以下循环但没有成功

import string    
for i in string.lowercase[0:2]:
block_blob_service.create_blob_from_path(
'my_container',
'xa%s' % i,
'/pathtomylocalfile/xa%s' % i)

虽然这有效

block_blob_service.create_blob_from_path(
'my_container',
'xaa',
'/pathtomylocalfile/xaa')

最佳答案

否则,您可以尝试使用format函数来格式化您的字符串:

...
block_blob_service.create_blob_from_path(
'my_container',
'xa{}'.format(i),
'/pathtomylocalfile/xa{}'.format(i))

关于python - azure Blob : upload directory content using a loop in Python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36935322/

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