简体   繁体   English

如何在Google App Engine项目上导入python文件?

[英]How to import python files on Google app engine project?

I recently started playing with Google app engine (GAE) and I'm failing to do something very simple. 我最近开始使用Google App Engine(GAE),但我做不到的事情很简单。

The GAE provides a main.py file which is where I'm trying to import a file I created util.py . GAE提供了一个main.py文件,这是我试图导入我创建的util.py文件的util.py

I saw some examples saying that you need to create a module for that in order to be able to include it. 我看到了一些示例,这些示例说明您需要为此创建一个模块才能包含它。

So I did 所以我做了

main.py 
utilities/ 
    __init__.py 
    util.py

In main.py I imported import utilities.util , I still can't call the functions inside of util.py. main.py我导入了import utilities.util ,但仍然无法调用util.py内部的函数。

Any ideas where I could learn more about these things? 有什么想法可以让我更多地了解这些东西吗?

import utilities.util as myutil
myutil.function_name()  #Using the module name you can access the functions


from utilities.util import function_name()
function_name()  

Ref: https://docs.python.org/3/tutorial/modules.html#modules 参考: https : //docs.python.org/3/tutorial/modules.html#modules

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

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