Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试通过运行检查目录是否存在
self.path = '~/foo' if not os.path.exists(self.path): os.makedirs(self.path)
在 Ubuntu 虚拟机上。尽管此目录不存在,但它不会创建该目录。事实上,使用 makedirs 命令正上方的 print 语句。知道它可能是什么吗?
你可能想os.path.expanduser先上路……
os.path.expanduser