Skip to content

Commit f4658d1

Browse files
committed
Shell commands
1 parent 492358c commit f4658d1

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
@@ -1685,14 +1685,14 @@ import os
16851685
<str> = os.popen('<shell_command>').read()
16861686
```
16871687

1688-
#### Sends '1 + 1' to a calculator and captures its output:
1688+
#### Sends '1 + 1' to the calculator and captures its output:
16891689
```python
16901690
>>> from subprocess import run
16911691
>>> run('bc', input='1 + 1\n', capture_output=True, encoding='utf-8')
16921692
CompletedProcess(args='bc', returncode=0, stdout='2\n', stderr='')
16931693
```
16941694

1695-
#### Sends 'test.in' to a calculator running in standard mode and saves its output to 'test.out':
1695+
#### Sends 'test.in' to the calculator running in standard mode and saves its output to 'test.out':
16961696
```python
16971697
>>> from shlex import split
16981698
>>> os.popen('echo 1 + 1 > test.in')

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,12 +1528,12 @@
15281528
&lt;str&gt; = os.popen(<span class="hljs-string">'&lt;shell_command&gt;'</span>).read()
15291529
</code></pre></div>
15301530

1531-
<div><h4 id="sends11toacalculatorandcapturesitsoutput">Sends '1 + 1' to a calculator and captures its output:</h4><pre><code class="python language-python hljs"><span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> subprocess <span class="hljs-keyword">import</span> run
1531+
<div><h4 id="sends11tothecalculatorandcapturesitsoutput">Sends '1 + 1' to the calculator and captures its output:</h4><pre><code class="python language-python hljs"><span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> subprocess <span class="hljs-keyword">import</span> run
15321532
<span class="hljs-meta">&gt;&gt;&gt; </span>run(<span class="hljs-string">'bc'</span>, input=<span class="hljs-string">'1 + 1\n'</span>, capture_output=<span class="hljs-keyword">True</span>, encoding=<span class="hljs-string">'utf-8'</span>)
15331533
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>)
15341534
</code></pre></div>
15351535

1536-
<div><h4 id="sendstestintoacalculatorrunninginstandardmodeandsavesitsoutputtotestout">Sends 'test.in' to a calculator running in standard mode and saves its output to 'test.out':</h4><pre><code class="python language-python hljs"><span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> shlex <span class="hljs-keyword">import</span> split
1536+
<div><h4 id="sendstestintothecalculatorrunninginstandardmodeandsavesitsoutputtotestout">Sends 'test.in' to the calculator running in standard mode and saves its output to 'test.out':</h4><pre><code class="python language-python hljs"><span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> shlex <span class="hljs-keyword">import</span> split
15371537
<span class="hljs-meta">&gt;&gt;&gt; </span>os.popen(<span class="hljs-string">'echo 1 + 1 &gt; test.in'</span>)
15381538
<span class="hljs-meta">&gt;&gt;&gt; </span>run(split(<span class="hljs-string">'bc -s'</span>), stdin=open(<span class="hljs-string">'test.in'</span>), stdout=open(<span class="hljs-string">'test.out'</span>, <span class="hljs-string">'w'</span>))
15391539
CompletedProcess(args=[<span class="hljs-string">'bc'</span>, <span class="hljs-string">'-s'</span>], returncode=<span class="hljs-number">0</span>)

0 commit comments

Comments
 (0)