Browse Source

Bytes

pull/188/head
Jure Šorn 5 months ago
parent
commit
75e960c525
2 changed files with 4 additions and 4 deletions
  1. 4
      README.md
  2. 4
      index.html

4
README.md

@ -1963,7 +1963,7 @@ Bytes
### Encode
```python
<bytes> = bytes(<coll_of_ints>) # Ints must be in range from 0 to 255.
<bytes> = bytes(<str>, 'utf-8') # Encodes string. Also <str>.encode('utf-8').
<bytes> = bytes(<str>, 'utf-8') # Encodes the string. Also <str>.encode().
<bytes> = bytes.fromhex('<hex>') # Hex pairs can be separated by whitespaces.
<bytes> = <int>.to_bytes(n_bytes, …) # `byteorder='big/little', signed=False`.
```
@ -1971,7 +1971,7 @@ Bytes
### Decode
```python
<list> = list(<bytes>) # Returns ints in range from 0 to 255.
<str> = str(<bytes>, 'utf-8') # Decodes bytes. Also <bytes>.decode('utf-8').
<str> = str(<bytes>, 'utf-8') # Returns a string. Also <bytes>.decode().
<str> = <bytes>.hex() # Returns hex pairs. Accepts `sep=<str>`.
<int> = int.from_bytes(<bytes>, …) # `byteorder='big/little', signed=False`.
```

4
index.html

@ -1623,13 +1623,13 @@ CompletedProcess(args=[<span class="hljs-string">'bc'</span>, <span class="hljs-
<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"># Encodes string. Also &lt;str&gt;.encode('utf-8').</span>
&lt;bytes&gt; = bytes(&lt;str&gt;, <span class="hljs-string">'utf-8'</span>) <span class="hljs-comment"># Encodes the string. Also &lt;str&gt;.encode().</span>
&lt;bytes&gt; = bytes.fromhex(<span class="hljs-string">'&lt;hex&gt;'</span>) <span class="hljs-comment"># Hex pairs can be separated by whitespaces.</span>
&lt;bytes&gt; = &lt;int&gt;.to_bytes(n_bytes, …) <span class="hljs-comment"># `byteorder='big/little', signed=False`.</span>
</code></pre></div>
<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"># Decodes bytes. Also &lt;bytes&gt;.decode('utf-8').</span>
&lt;str&gt; = str(&lt;bytes&gt;, <span class="hljs-string">'utf-8'</span>) <span class="hljs-comment"># Returns a string. Also &lt;bytes&gt;.decode().</span>
&lt;str&gt; = &lt;bytes&gt;.hex() <span class="hljs-comment"># Returns hex pairs. Accepts `sep=&lt;str&gt;`.</span>
&lt;int&gt; = int.from_bytes(&lt;bytes&gt;, …) <span class="hljs-comment"># `byteorder='big/little', signed=False`.</span>
</code></pre></div>

Loading…
Cancel
Save