Browse Source

Bytes

pull/44/head
Jure Šorn 5 years ago
parent
commit
1d5bfb2577
2 changed files with 6 additions and 6 deletions
  1. 4
      README.md
  2. 8
      index.html

4
README.md

@ -1861,16 +1861,16 @@ Bytes
### Encode
```python
<bytes> = bytes(<str>, 'utf-8') # Or: <str>.encode('utf-8')
<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
```python
<str> = str(<bytes>, 'utf-8') # Or: <bytes>.decode('utf-8')
<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()
```

8
index.html

@ -1658,14 +1658,14 @@ db = connector.connect(host=&lt;str&gt;, user=&lt;str&gt;, password=&lt;str&gt;,
</code></pre></div>
<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>
&lt;bytes&gt; = bytes(&lt;coll_of_ints&gt;) <span class="hljs-comment"># Ints must be in range from 0 to 255.</span>
<div><h3 id="encode-1">Encode</h3><pre><code class="python language-python hljs">&lt;bytes&gt; = bytes(&lt;coll_of_ints&gt;) <span class="hljs-comment"># Ints must be in range from 0 to 255.</span>
&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>
&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>)
&lt;bytes&gt; = bytes.fromhex(<span class="hljs-string">'&lt;hex&gt;'</span>)
</code></pre></div>
<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>
&lt;list&gt; = list(&lt;bytes&gt;) <span class="hljs-comment"># Returns ints in range from 0 to 255.</span>
<div><h3 id="decode-1">Decode</h3><pre><code class="python language-python hljs">&lt;list&gt; = list(&lt;bytes&gt;) <span class="hljs-comment"># Returns ints in range from 0 to 255.</span>
&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>
&lt;int&gt; = int.from_bytes(&lt;bytes&gt;, byteorder=<span class="hljs-string">'big|little'</span>, signed=<span class="hljs-keyword">False</span>)
<span class="hljs-string">'&lt;hex&gt;'</span> = &lt;bytes&gt;.hex()
</code></pre></div>

Loading…
Cancel
Save