Python 3.x python3和scrapy路径

Python 3.x python3和scrapy路径,python-3.x,scrapy,Python 3.x,Scrapy,1、 python3程序,如何从不同目录导入模块 2、 如何获取scrapy的路径信息 3、 从rugplation.custom_module.rule_module导入爬网规则,ParserRule ImportError:没有名为“RUGplatform”的模块我的解决方案: import os import sys sys.path.append('/'.join(os.path.split(os.path.realpath(__file__))[0].split('/')[0:-2]

1、 python3程序,如何从不同目录导入模块
2、 如何获取scrapy的路径信息

3、 从rugplation.custom_module.rule_module导入爬网规则,ParserRule
ImportError:没有名为“RUGplatform”的模块

我的解决方案:

import os
import sys
sys.path.append('/'.join(os.path.split(os.path.realpath(__file__))[0].split('/')[0:-2]))<br>
from RUGplatform.custom_module.rule_module import CrawlRule, ParserRule
导入操作系统
导入系统
sys.path.append('/'.join(os.path.split(os.path.realpath(_文件__))[0]。split('/')[0:-2])
从rugplation.custom_module.rule_module导入爬网规则,ParserRule

有更优雅的解决方案吗?例如,来自scrapy framework的解决方案重复了问题,请参阅下面的帖子。谢谢,但我的问题可能不同,我想知道框架的作用