Python的一个临时目录中创建一个嵌套的目录

问题描述 投票:0回答:2

我正在使用Python(3.7)中,我需要创建一个临时目录中的子目录的一个项目,我已经创建了我的临时目录:

tempdir = tempfile.mkdtemp()
saved_unmask = os.umask(0o077)
temp_dir = os.path.join(tempdir)

然后我试图创建这个temp_dir作为内的目录:

helm_chart = temp_dir + "/helmChart"
subprocess2.call(['helm', 'create', helm_chart])

helm creates path/sub_path始终创建内部path目录是temp_dir在我的情况下,command上面创建一个目录时,我通过另一个目录路径,但它不是建立内部temp_dir的目录。

提前致谢!

python python-3.x temporary-files
2个回答
0
投票

以下可能的工作:

import os
os.makedirs(os.path.join(tempdir, 'helmChart'))

0
投票

你有saved_unmask = os.umask(0o077),是你的脚本运行用户下?也许它没有写权限的临时目录

© www.soinside.com 2019 - 2024. All rights reserved.