Skip to content

Commit 3c2bb65

Browse files
committed
Bytes
1 parent 8c82f7c commit 3c2bb65

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1861,15 +1861,15 @@ Bytes
18611861

18621862
### Encode
18631863
```python
1864-
<bytes> = <str>.encode('utf-8') # Or: bytes(<str>, 'utf-8')
1864+
<bytes> = bytes(<str>, 'utf-8') # Or: <str>.encode('utf-8')
18651865
<bytes> = bytes(<coll_of_ints>) # Ints must be in range from 0 to 255.
18661866
<bytes> = <int>.to_bytes(n_bytes, byteorder='big|little', signed=False)
18671867
<bytes> = bytes.fromhex('<hex>')
18681868
```
18691869

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

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1658,13 +1658,13 @@
16581658
</code></pre></div>
16591659

16601660

1661-
<div><h3 id="encode-1">Encode</h3><pre><code class="python language-python hljs">&lt;bytes&gt; = &lt;str&gt;.encode(<span class="hljs-string">'utf-8'</span>) <span class="hljs-comment"># Or: bytes(&lt;str&gt;, 'utf-8')</span>
1661+
<div><h3 id="encode-1">Encode</h3><pre><code class="python language-python hljs">&lt;bytes&gt; = bytes(&lt;str&gt;, <span class="hljs-string">'utf-8'</span>) <span class="hljs-comment"># Or: &lt;str&gt;.encode('utf-8')</span>
16621662
&lt;bytes&gt; = bytes(&lt;coll_of_ints&gt;) <span class="hljs-comment"># Ints must be in range from 0 to 255.</span>
16631663
&lt;bytes&gt; = &lt;int&gt;.to_bytes(n_bytes, byteorder=<span class="hljs-string">'big|little'</span>, signed=<span class="hljs-keyword">False</span>)
16641664
&lt;bytes&gt; = bytes.fromhex(<span class="hljs-string">'&lt;hex&gt;'</span>)
16651665
</code></pre></div>
16661666

1667-
<div><h3 id="decode-1">Decode</h3><pre><code class="python language-python hljs">&lt;str&gt; = &lt;bytes&gt;.decode(<span class="hljs-string">'utf-8'</span>) <span class="hljs-comment"># Or: str(&lt;bytes&gt;, 'utf-8')</span>
1667+
<div><h3 id="decode-1">Decode</h3><pre><code class="python language-python hljs">&lt;str&gt; = str(&lt;bytes&gt;, <span class="hljs-string">'utf-8'</span>) <span class="hljs-comment"># Or: &lt;bytes&gt;.decode('utf-8')</span>
16681668
&lt;list&gt; = list(&lt;bytes&gt;) <span class="hljs-comment"># Returns ints in range from 0 to 255.</span>
16691669
&lt;int&gt; = int.from_bytes(&lt;bytes&gt;, byteorder=<span class="hljs-string">'big|little'</span>, signed=<span class="hljs-keyword">False</span>)
16701670
<span class="hljs-string">'&lt;hex&gt;'</span> = &lt;bytes&gt;.hex()

0 commit comments

Comments
 (0)