File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -172,6 +172,15 @@ included in one of the following places:
172172 except ImportError:
173173 from importlib.resources import files
174174
175+ After this import, you can:
176+
177+ - open a resource for text reading: `fd = files(package).joinpath(resource).open('rt') `
178+ - open a resource for binary reading: `fd = files(package).joinpath(resource).open('rb') `
179+ - read a resource as text: `text = files(package).joinpath(resource).read_text() `
180+ - read a resource as bytes: `bytes = files(package).joinpath(resource).read_bytes() `
181+ - open a xz resource for text reading: `fd = lzma.open(files(package).joinpath(resource), 'rt') `
182+ - open a xz resource for binary reading: `fd = lzma.open(files(package).joinpath(resource), 'rb') `
183+
175184 If the file needs to be used outside of Python, then the
176185 preferred way is using the context manager
177186 :func: `importlib.resources.as_file `. It should be imported as
You can’t perform that action at this time.
0 commit comments