Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
将配置文件添加到包中并不是什么大问题。但是当我将包上传到 pypi 并安装它时,无法读取日志配置:
logging.config.fileConfig('logging.conf')
基本上我的模块找不到它,因为文件不再位于当前工作目录中。我该如何解决这个问题?
如果logging.conf与调用的文件存在于同一目录中logging.config.fileConfig,则可以使用:
logging.conf
logging.config.fileConfig
import os logconf_file = os.path.join(os.path.dirname(__file__), 'logging.conf') logging.config.fileConfig(logconf_file)