Browse Source

Bytes and Struct

pull/3/head
Jure Šorn 6 years ago
parent
commit
d21fd18282
1 changed files with 5 additions and 9 deletions
  1. 14
      README.md

14
README.md

@ -639,21 +639,17 @@ Bytes
----- -----
**Bytes objects are immutable sequences of single bytes.** **Bytes objects are immutable sequences of single bytes.**
#### Str:
### Encode
```python ```python
<Bytes> = b'<str>' <Bytes> = b'<str>'
<str> = <Bytes>.decode('utf-8')
```
#### Int:
```python
<Bytes> = <int>.to_bytes(<length>, byteorder='big|small', signed=False) <Bytes> = <int>.to_bytes(<length>, byteorder='big|small', signed=False)
<int> = int.from_bytes(<Bytes>, byteorder='big|small', signed=False)
<Bytes> = bytes.fromhex(<hex>)
``` ```
#### Hex:
### Decode
```python ```python
<Bytes> = bytes.fromhex(<hex>)
<str> = <Bytes>.decode('utf-8')
<int> = int.from_bytes(<Bytes>, byteorder='big|small', signed=False)
<hex> = <Bytes>.hex() <hex> = <Bytes>.hex()
``` ```

Loading…
Cancel
Save