如何使用python脚本访问卷装载?

2024-05-28 19:11:25 发布

您现在位置:Python中文网/ 问答频道 /正文

我一直在尝试使用以下方法来访问卷装载中的文件:

with open('./log/file.json', 'w+') as f:
    f.write(json.dumps(output, sort_keys=True, indent=4))

但它不起作用。有什么想法吗?在部署文件中,我有:

volumeMounts:
- mountPath: /logs
  name: wag-log

Tags: 文件方法logjsontrueoutputaswith
1条回答
网友
1楼 · 发布于 2024-05-28 19:11:25

您已经定义了一个volumeMountmountPath设置为/logs,这将把一个卷装入/logs目录。在Python代码中,您是在路径./log/file.json处编写的,该路径不在/logs中。你知道吗

尝试将日志写入已装入的目录,例如:

with open('/logs/file.json', 'w+') as f:
    f.write(json.dumps(output, sort_keys=True, indent=4))

相关问题 更多 >

    热门问题