문제

I'm attempting check if a directory exists by running

self.path = '~/foo'
    if not os.path.exists(self.path):
        os.makedirs(self.path)

On an Ubuntu virtual machine. Although this directory does not exist, it does not make the directory. In fact using a print statement right above the makedirs command. Any idea what it could be?

도움이 되었습니까?

해결책

You probably want to os.path.expanduser on the path first...

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top