This commit is contained in:
parent
f53d9c23ca
commit
e6eb8b3746
17
README.md
17
README.md
@ -18,13 +18,18 @@ $ pip install pyvarint
|
|||||||
## Example
|
## Example
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from random import sample
|
|
||||||
from pyvarint import decode, encode
|
from pyvarint import decode, encode
|
||||||
|
|
||||||
ten_rand_ints = sample(range(100), 10)
|
encoded = encode(666)
|
||||||
|
decoded = decode(encoded)
|
||||||
|
|
||||||
for rand_int in ten_rand_ints:
|
print("number: 666", f"encoded: {encoded}", f"decoded: {decoded}", sep="\n")
|
||||||
encoded = encode(rand_int)
|
```
|
||||||
decoded = decode(encoded)
|
|
||||||
assert decoded == rand_int
|
Output:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
number: 666
|
||||||
|
encoded: b'\x9a\x05'
|
||||||
|
decoded: 666
|
||||||
```
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user