Skip to content

Instantly share code, notes, and snippets.

@punkmonday
Created October 11, 2016 08:28
Show Gist options
  • Save punkmonday/984a18b866b938dcce44111a4d39d38d to your computer and use it in GitHub Desktop.
Save punkmonday/984a18b866b938dcce44111a4d39d38d to your computer and use it in GitHub Desktop.
__init__.py里import的模块,实际运行的时候是在当前的目录(就是你目前所在的目录)寻找package,而不是__init__.py所在目录,所以就会导致找不到模块
所以要真正能导入,需要
import sys
sys.path.append("__init__.py所在目录")
之后
import 的模块就会到append的路径里查找模块了
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment