Fix up README example
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Luke Murphy 2020-08-05 08:28:38 +02:00
parent f53d9c23ca
commit e6eb8b3746
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC

View File

@ -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)
for rand_int in ten_rand_ints:
encoded = encode(rand_int)
decoded = decode(encoded) decoded = decode(encoded)
assert decoded == rand_int
print("number: 666", f"encoded: {encoded}", f"decoded: {decoded}", sep="\n")
```
Output:
```sh
number: 666
encoded: b'\x9a\x05'
decoded: 666
``` ```