Using Python's os.path, how do I go up one directory?

前端 未结 14 1796
陌清茗
陌清茗 2020-12-07 07:47

I recently upgrade Django from v1.3.1 to v1.4.

In my old settings.py I have

TEMPLATE_DIRS = (
    os.path.join(os.path.dirname( __file_         


        
14条回答
  •  忘掉有多难
    2020-12-07 08:27

    With using os.path we can go one directory up like that

    one_directory_up_path = os.path.dirname('.')
    

    also after finding the directory you want you can join with other file/directory path

    other_image_path = os.path.join(one_directory_up_path, 'other.jpg')
    

提交回复
热议问题