[英]Best way to handle files used by python module
I have a module in site-packages that uses collection of binary files. 我在站点软件包中有一个模块,该模块使用二进制文件的集合。 Besides hard-coding the absolute paths of these files in the module, is there a better way to handle this module-datafile dependency?
除了在模块中硬编码这些文件的绝对路径外,还有没有更好的方法来处理此模块数据文件依赖性?
Put the data file in a place relative to the module. 将数据文件放置在相对于模块的位置。 Use inspect module to figure out the path of the module and then read the data file using this information.
使用检查模块找出模块的路径,然后使用此信息读取数据文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.