[英]How to import python script files in folders on Google App Engine?
I'm fairly new to both Python and Google App Engine. 我对Python和Google App Engine都很陌生。 I want to organize my script files by creating a folder structure.
我想通过创建文件夹结构来组织我的脚本文件。 However when I do that I can no longer figure out how to import them.
但是,当我这样做时,我再也无法弄清楚如何导入它们。
For example: 例如:
main.py
/eggs/spam.py
How do I import spam.py in main.py? 如何在main.py中导入spam.py?
Make eggs a package by adding an __init__.py
file in the folder. 通过在文件夹中添加
__init__.py
文件使鸡蛋成为包。 It can be empty, as long as it's there. 它可以是空的,只要它在那里。 Then, import spam like this:
然后,像这样导入垃圾邮件:
import eggs.spam
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.