在python模块上导入类时遇到问题
以下是我的目录结构:
TestMap
+lib
+vendors
+testing
- _init.py
- products.py
- _init_py.
- notifications.py
- scraper.py
- utils.py
-main.py
我从scraper.py
开始,尝试在products.py上获取函数,它是vendors -> testing -> products.py
from .vendors.testing.products import TestProducts
我想做的是:
ImportError: cannot import name 'TestProducts' from 'lib.vendors.testing.products' (C:\Users\Annoynmous\Desktop\TestMap\lib\vendors\testing\products.py)
在products.py中,类名是:
class TestProducts():
而我却不知道我到底做错了什么
在scraper.py中尝试此操作
或
使用
self.product
访问类scraper中TestProducts的任何函数使用
pythonpath
在项目中设置源目录:并从该源路径导入模块
或者使用
__init__.py
文件定义内部模块目录,并使用直接模块名导入模块相关问题 更多 >
编程相关推荐