我正在尝试从本地计算机上的.yaml
文件中读取数据。但是,当我导入文件并打印数据时,它位于一行中。供参考的屏幕快照在这里:
但是,通过使用Jupiter笔记本,我能够以所需的字典格式成功读取数据。截图供参考
如何在Colab中按行字典格式读取数据?
答案 0 :(得分:0)
根据the docs,
files.upload
返回上载文件的字典。
所以你需要做
uploaded = files.upload()
for key, value in uploaded.items():
data = yaml.load(value)
print(key) # prints the file name
print(data) # prints the loaded data
答案 1 :(得分:0)
尝试一下
data = yaml.load(data["ipl_match.yaml"])