Relative paths in Python

前端 未结 15 1677
陌清茗
陌清茗 2020-11-22 07:39

I\'m building a simple helper script for work that will copy a couple of template files in our code base to the current directory. I don\'t, however, have the absolute path

15条回答
  •  一个人的身影
    2020-11-22 08:03

    What worked for me is using sys.path.insert. Then I specified the directory I needed to go. For example I just needed to go up one directory.

    import sys
    sys.path.insert(0, '../')
    

提交回复
热议问题