Browse Source

Struct

pull/102/merge
Jure Šorn 4 weeks ago
parent
commit
40c12e4419
2 changed files with 8 additions and 8 deletions
  1. 8
      README.md
  2. 8
      index.html

8
README.md

@ -1741,7 +1741,7 @@ shutil.rmtree(<path>) # Deletes the directory.
<int> = <pipe>.close() # Returns None if last command exited with returncode 0.
```
#### Sends '1 + 1' to the basic calculator and captures its output:
#### Sends "1 + 1" to the basic calculator and captures its output:
```python
>>> subprocess.run('bc', input='1 + 1\n', capture_output=True, text=True)
CompletedProcess(args='bc', returncode=0, stdout='2\n', stderr='')
@ -1910,7 +1910,7 @@ with <conn>: # Exits the block with commit() o
### Placeholders
```python
<conn>.execute('<query>', <list/tuple>) # Replaces every question mark with an item.
<conn>.execute('<query>', <dict/namedtuple>) # Replaces every :<key> with value.
<conn>.execute('<query>', <dict/namedtuple>) # Replaces every :<key> with a value.
<conn>.executemany('<query>', <coll_of_coll>) # Runs execute() multiple times.
```
* **Passed values can be of type str, int, float, bytes, None, or bool (stored as 1 or 0).**
@ -1999,8 +1999,8 @@ Struct
```python
from struct import pack, unpack
<bytes> = pack('<format>', <num_1> [, ...]) # Packs numbers according to format string.
<tuple> = unpack('<format>', <bytes>) # Use iter_unpack() to get iterator of tuples.
<bytes> = pack('<format>', <el_1> [, ...]) # Packs numbers according to format string.
<tuple> = unpack('<format>', <bytes>) # Use iter_unpack() to get iterator of tuples.
```
```python

8
index.html

@ -1473,7 +1473,7 @@ shutil.rmtree(&lt;path&gt;) <span class="hljs-comment"># Deletes t
&lt;int&gt; = &lt;pipe&gt;.close() <span class="hljs-comment"># Returns None if last command exited with returncode 0.</span>
</code></pre></div>
<div><h4 id="sends11tothebasiccalculatorandcapturesitsoutput">Sends '1 + 1' to the basic calculator and captures its output:</h4><pre><code class="python language-python hljs"><span class="hljs-meta">&gt;&gt;&gt; </span>subprocess.run(<span class="hljs-string">'bc'</span>, input=<span class="hljs-string">'1 + 1\n'</span>, capture_output=<span class="hljs-keyword">True</span>, text=<span class="hljs-keyword">True</span>)
<div><h4 id="sends11tothebasiccalculatorandcapturesitsoutput">Sends "1 + 1" to the basic calculator and captures its output:</h4><pre><code class="python language-python hljs"><span class="hljs-meta">&gt;&gt;&gt; </span>subprocess.run(<span class="hljs-string">'bc'</span>, input=<span class="hljs-string">'1 + 1\n'</span>, capture_output=<span class="hljs-keyword">True</span>, text=<span class="hljs-keyword">True</span>)
CompletedProcess(args=<span class="hljs-string">'bc'</span>, returncode=<span class="hljs-number">0</span>, stdout=<span class="hljs-string">'2\n'</span>, stderr=<span class="hljs-string">''</span>)
</code></pre></div>
@ -1597,7 +1597,7 @@ CompletedProcess(args=[<span class="hljs-string">'bc'</span>, <span class="hljs-
</code></pre></div>
<div><h3 id="placeholders">Placeholders</h3><pre><code class="python language-python hljs">&lt;conn&gt;.execute(<span class="hljs-string">'&lt;query&gt;'</span>, &lt;list/tuple&gt;) <span class="hljs-comment"># Replaces every question mark with an item.</span>
&lt;conn&gt;.execute(<span class="hljs-string">'&lt;query&gt;'</span>, &lt;dict/namedtuple&gt;) <span class="hljs-comment"># Replaces every :&lt;key&gt; with value.</span>
&lt;conn&gt;.execute(<span class="hljs-string">'&lt;query&gt;'</span>, &lt;dict/namedtuple&gt;) <span class="hljs-comment"># Replaces every :&lt;key&gt; with a value.</span>
&lt;conn&gt;.executemany(<span class="hljs-string">'&lt;query&gt;'</span>, &lt;coll_of_coll&gt;) <span class="hljs-comment"># Runs execute() multiple times.</span>
</code></pre></div>
@ -1665,8 +1665,8 @@ CompletedProcess(args=[<span class="hljs-string">'bc'</span>, <span class="hljs-
<li><strong>System’s type sizes, byte order, and alignment rules are used by default.</strong></li>
</ul><pre><code class="python language-python hljs"><span class="hljs-keyword">from</span> struct <span class="hljs-keyword">import</span> pack, unpack
&lt;bytes&gt; = pack(<span class="hljs-string">'&lt;format&gt;'</span>, &lt;num_1&gt; [, ...]) <span class="hljs-comment"># Packs numbers according to format string.</span>
&lt;tuple&gt; = unpack(<span class="hljs-string">'&lt;format&gt;'</span>, &lt;bytes&gt;) <span class="hljs-comment"># Use iter_unpack() to get iterator of tuples.</span>
&lt;bytes&gt; = pack(<span class="hljs-string">'&lt;format&gt;'</span>, &lt;el_1&gt; [, ...]) <span class="hljs-comment"># Packs numbers according to format string.</span>
&lt;tuple&gt; = unpack(<span class="hljs-string">'&lt;format&gt;'</span>, &lt;bytes&gt;) <span class="hljs-comment"># Use iter_unpack() to get iterator of tuples.</span>
</code></pre></div>

Loading…
Cancel
Save