简体   繁体   中英

How do I link to another directory with python?

In blog.py template_dir = os.path.join(os.path.dirname( file ), 'templates')

^I know this is the way to search for the templates folder in the same directory, but what about sibling directories (ie other folders of the current folder's parent)

The problem is:

Current File WebAppName/Backend/blog.py

How Do I Reference? WebAppName/Frontend/templates/

What should I change template_dir to in order to access templates in the Frontend folder

template_dir = os.path.abspath(
               os.path.join(os.path.dirname(__file__),
                            '../Frontend/templates'))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM