简体   繁体   English

如何使用python链接到另一个目录?

[英]How do I link to another directory with python?

In blog.py template_dir = os.path.join(os.path.dirname( file ), 'templates') 在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 当前文件WebAppName / Backend / blog.py

How Do I Reference? 我如何参考? WebAppName/Frontend/templates/ WebAppName / Frontend / templates /

What should I change template_dir to in order to access templates in the Frontend folder 我应该将template_dir更改为什么才能访问Frontend文件夹中的模板

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我如何在较低的目录中运行另一个 Python 文件 - How do i run another Python file in a lower directory 对于Python 3,如何从另一个目录导入.py文件? - For Python 3, how do I import a .py file from another directory? 如何将目录中子文件夹中的文件移动到python中的另一个目录? - How do I move files within a subfolder in a directory to another directory in python? 如何在另一个文件目录中的另一个脚本中导入Python文件? - How do I import a Python file within another script which is in another file directory? 如何导入另一个目录中的文件? - How do I import a file that is in another directory? 如何在与另一个python文件不同的目录中运行python文件? - How do I run a python file in a different directory from another python file? 如何使用Selenium-Python从网站上项目的另一个目录上载图像? - How do I upload an image from another directory of my project on web site with Selenium - Python? 如何使用 python 将几个文件夹从一个目录复制到 Linux 中的另一个文件夹 - how do I copy over a few folders from one directory into another folder in Linux using python 如何在Python中运行bash脚本,但就好像它从另一个目录运行? - How do I run a bash script inside Python, but act as if it's running from another directory? 提取目录中的文件夹名称列表后,如何使用 Python 将它们重命名为另一种格式? - After extracting the list of folder names in a directory, how do I rename them in another format using Python?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM