From 1d5bfb257734336e8004df80c3dfab0253181db2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Mon, 16 Sep 2019 14:52:36 +0200 Subject: [PATCH] Bytes --- README.md | 4 ++-- index.html | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 16a7a11..09d0daf 100644 --- a/README.md +++ b/README.md @@ -1861,16 +1861,16 @@ Bytes ### Encode ```python - = bytes(, 'utf-8') # Or: .encode('utf-8') = bytes() # Ints must be in range from 0 to 255. + = bytes(, 'utf-8') # Or: .encode('utf-8') = .to_bytes(n_bytes, byteorder='big|little', signed=False) = bytes.fromhex('') ``` ### Decode ```python - = str(, 'utf-8') # Or: .decode('utf-8') = list() # Returns ints in range from 0 to 255. + = str(, 'utf-8') # Or: .decode('utf-8') = int.from_bytes(, byteorder='big|little', signed=False) '' = .hex() ``` diff --git a/index.html b/index.html index 9381133..dfddda6 100644 --- a/index.html +++ b/index.html @@ -1658,14 +1658,14 @@ db = connector.connect(host=<str>, user=<str>, password=<str>, -

Encode

<bytes> = bytes(<str>, 'utf-8')          # Or: <str>.encode('utf-8')
-<bytes> = bytes(<coll_of_ints>)          # Ints must be in range from 0 to 255.
+

Encode

<bytes> = bytes(<coll_of_ints>)          # Ints must be in range from 0 to 255.
+<bytes> = bytes(<str>, 'utf-8')          # Or: <str>.encode('utf-8')
 <bytes> = <int>.to_bytes(n_bytes, byteorder='big|little', signed=False)
 <bytes> = bytes.fromhex('<hex>')
 
-

Decode

<str>   = str(<bytes>, 'utf-8')          # Or: <bytes>.decode('utf-8')
-<list>  = list(<bytes>)                  # Returns ints in range from 0 to 255.
+

Decode

<list>  = list(<bytes>)                  # Returns ints in range from 0 to 255.
+<str>   = str(<bytes>, 'utf-8')          # Or: <bytes>.decode('utf-8')
 <int>   = int.from_bytes(<bytes>, byteorder='big|little', signed=False)
 '<hex>' = <bytes>.hex()