我正在使用以下代码创建一个 _GeneratorContextManager。
try:
import importlib.resources as pkg_resources
except ImportError:
# Try backported to PY<37 `importlib_resources`.
import importlib_resources as pkg_resources
from . import file_resources
package_path= pkg_resources.path(file_resources, "IWNLP.Lemmatizer_20181001.json")
Run Code Online (Sandbox Code Playgroud)
这是变量 package_path 的调试器视图。
现在我想将文件“IWNLP.Lemmatizer_20181001.json”的路径传递给另一个函数:
lemmatizer = IWNLPWrapper(lemmatizer_path=package_path)
Run Code Online (Sandbox Code Playgroud)
文档说“上下文管理器提供了一个 pathlib.Path 对象”。如何访问 pathlib.Path 对象?