The zs
library for Python¶
Quickstart¶
Using the example file we created when demonstrating zs make, we can write:
In [1]: from zs import ZS
In [2]: z = ZS("example/tiny-4grams.zs")
In [3]: for record in z:
...: print(record.decode("utf-8"))
...:
not done explicitly . 42
not done extensive research 225
not done extensive testing 749
not done extensive tests 87
not done extremely well 41
not done fairly . 61
not done fast , 52
not done fast enough 71
# Notice that on Python 3.x, we search using byte strings, and we get
# byte strings back.
# (On Python 2.x, byte strings are the same as regular strings.)
In [4]: for record in z.search(prefix=b"not done extensive testing\t"):
...: print(record.decode("utf-8"))
...: