Normally, when importing a module, Python tries to find the module
file next to the importing module (the module that contains the import
statement). Python then tries the directories in “sys.path”. The
current working directory is usually not considered. In our case, the
import is performed via the API, so there is no importing module in
whose directory Python could search for “shout_filter.py”. The plug-in
is also not on “sys.path”. One way of enabling Python to find the
plug-in is to add the current working directory to the module search
path by doing the equivalent of “sys.path.append(‘.’)” via the API.
有一个很好的方法,因为这是它经常与网站包装的方式。
或者你用
在进口之前。
另一种方式是丑陋的:
也许你要求一个C函数来完成你的工作,但我不知道。
我在http://realmike.org/blog/2012/07/08/embedding-python-tutorial-part-1/找到了我想要的答案
SplitFilename
是我为获取目录而编写的函数。相关问题 更多 >
编程相关推荐