File tree Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -1861,15 +1861,15 @@ Bytes
1861
1861
1862
1862
### Encode
1863
1863
``` python
1864
- < bytes > = < str > .encode( ' utf-8' ) # Or: bytes( <str>, 'utf-8')
1864
+ < bytes > = bytes ( < str > , ' utf-8' ) # Or: <str>.encode( 'utf-8')
1865
1865
< bytes > = bytes (< coll_of_ints> ) # Ints must be in range from 0 to 255.
1866
1866
< bytes > = < int > .to_bytes(n_bytes, byteorder = ' big|little' , signed = False )
1867
1867
< bytes > = bytes .fromhex(' <hex>' )
1868
1868
```
1869
1869
1870
1870
### Decode
1871
1871
``` python
1872
- < str > = < bytes > .decode( ' utf-8' ) # Or: str( <bytes>, 'utf-8')
1872
+ < str > = str ( < bytes > , ' utf-8' ) # Or: <bytes>.decode( 'utf-8')
1873
1873
< list > = list (< bytes > ) # Returns ints in range from 0 to 255.
1874
1874
< int > = int .from_bytes(< bytes > , byteorder = ' big|little' , signed = False )
1875
1875
' <hex>' = < bytes > .hex()
Original file line number Diff line number Diff line change 1658
1658
</ code > </ pre > </ div >
1659
1659
1660
1660
1661
- < div > < h3 id ="encode-1 "> Encode</ h3 > < pre > < code class ="python language-python hljs "> <bytes> = <str>.encode( < span class ="hljs-string "> 'utf-8'</ span > ) < span class ="hljs-comment "> # Or: bytes( <str>, 'utf-8')</ span >
1661
+ < div > < h3 id ="encode-1 "> Encode</ h3 > < pre > < code class ="python language-python hljs "> <bytes> = bytes( <str>, < span class ="hljs-string "> 'utf-8'</ span > ) < span class ="hljs-comment "> # Or: <str>.encode( 'utf-8')</ span >
1662
1662
<bytes> = bytes(<coll_of_ints>) < span class ="hljs-comment "> # Ints must be in range from 0 to 255.</ span >
1663
1663
<bytes> = <int>.to_bytes(n_bytes, byteorder=< span class ="hljs-string "> 'big|little'</ span > , signed=< span class ="hljs-keyword "> False</ span > )
1664
1664
<bytes> = bytes.fromhex(< span class ="hljs-string "> '<hex>'</ span > )
1665
1665
</ code > </ pre > </ div >
1666
1666
1667
- < div > < h3 id ="decode-1 "> Decode</ h3 > < pre > < code class ="python language-python hljs "> <str> = <bytes>.decode( < span class ="hljs-string "> 'utf-8'</ span > ) < span class ="hljs-comment "> # Or: str( <bytes>, 'utf-8')</ span >
1667
+ < div > < h3 id ="decode-1 "> Decode</ h3 > < pre > < code class ="python language-python hljs "> <str> = str( <bytes>, < span class ="hljs-string "> 'utf-8'</ span > ) < span class ="hljs-comment "> # Or: <bytes>.decode( 'utf-8')</ span >
1668
1668
<list> = list(<bytes>) < span class ="hljs-comment "> # Returns ints in range from 0 to 255.</ span >
1669
1669
<int> = int.from_bytes(<bytes>, byteorder=< span class ="hljs-string "> 'big|little'</ span > , signed=< span class ="hljs-keyword "> False</ span > )
1670
1670
< span class ="hljs-string "> '<hex>'</ span > = <bytes>.hex()
You can’t perform that action at this time.
0 commit comments