Python doesn't find a directory using the home sign ~

后端 未结 2 1797
日久生厌
日久生厌 2020-12-11 08:47

I have created a small Python script to save directories in a side directory, under the current user. I am running on Mac but production is Ubuntu

My problem is the

2条回答
  •  庸人自扰
    2020-12-11 09:08

    os.environ["HOME"] = "/Users/partuck/
    os.path.expanduser("~/cache_dir/bla")
    

    (@jedwards answer pointed out expanduser)

提交回复
热议问题