【发布时间】:2022-08-02 21:04:30
【问题描述】:
您好我正在尝试使用 python 将文件上传到 blob 存储中,但是这样做时我收到以下错误
TypeError:字符串索引必须是整数
目前我的代码看起来像这样
import os
import yaml
from azure.storage.blob import ContainerClient
def load_config():
dir_root = os.path.dirname(os.path.abspath(__file__))
with open(dir_root + \"/config.yaml\",\"r\") as yamlfile:
return yaml.load(yamlfile, Loader=yaml.FullLoader)
def get_files(dir):
with os.scandir(dir) as entries:
for entry in entries:
if entry.is_file() and not entry.name.startswith(\'.\'):
yield entry
config =load_config()
csvs =get_files(config[\"source_folder\"]+\"/csvs\")
print(*csvs)
-
哪一行是错误?是用于 config[\"source_folder\"] 的吗?你确定 config 是一个 dict{} 吗?
-
是的是的。这是正确的。我通过参考这个视频制作了这个程序youtube.com/watch?v=enhJfb_6KYU
-
请提供问题中格式化的整个堆栈跟踪
-
打印配置类型并仔细检查
标签: python string azure azure-blob-storage