Python:os.path.exists在“上失败”~/"富",;
我试图通过运行来检查目录是否存在Python:os.path.exists在“上失败”~/"富",;,python,ubuntu,directory,os.path,Python,Ubuntu,Directory,Os.path,我试图通过运行来检查目录是否存在 self.path = '~/foo' if not os.path.exists(self.path): os.makedirs(self.path) 在Ubuntu虚拟机上。虽然此目录不存在,但它不构成目录。实际上,使用makedirs命令正上方的print语句。你知道它可能是什么吗?你可能想先在路径上使用os.path.expanduser
self.path = '~/foo'
if not os.path.exists(self.path):
os.makedirs(self.path)
在Ubuntu虚拟机上。虽然此目录不存在,但它不构成目录。实际上,使用makedirs命令正上方的print语句。你知道它可能是什么吗?你可能想先在路径上使用
os.path.expanduser