how to properly please yourself(How to properly use relative or absolute imports in Python modules? Stack Overflow)
导读:Ditch relative imports: you should think of your package namespace as a global one, anyway....
Ditch relative imports: you should think of your package namespace as a global one, anyway.
The trick to making this palatable is editing sys.path appropriately. Here is some food for thought:
# one directory up _root_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) sys.path.insert(0, _root_dir)for now创心域SEO版权声明:以上内容作者已申请原创保护,未经允许不得转载,侵权必究!授权事宜、对本内容有异议或投诉,敬请联系网站管理员,我们将尽快回复您,谢谢合作!