Browse Source

Command execution

pull/36/head
Jure Šorn 5 years ago
parent
commit
6b587695f8
2 changed files with 14 additions and 14 deletions
  1. 14
      README.md
  2. 14
      index.html

14
README.md

@ -1589,19 +1589,19 @@ Command Execution
```python
import os
os.chdir(<path>) # Changes the current working directory.
<str> = os.getcwd() # Returns current working directory.
os.chdir(<path>) # Changes the current working directory.
<str> = os.getcwd() # Returns current working directory.
```
```python
os.remove(<path>) # Deletes the file.
os.rmdir(<path>) # Deletes empty directory.
shutil.rmtree(<path>) # Deletes an entire directory tree.
os.remove(<path>) # Deletes the file.
os.rmdir(<path>) # Deletes empty directory.
shutil.rmtree(<path>) # Deletes an entire directory tree.
```
```python
os.rename(from, to) # Renames the file or directory.
os.replace(from, to) # Same, but overwrites 'to' if it exists.
os.rename(from, to) # Renames the file or directory.
os.replace(from, to) # Same, but overwrites 'to' if it exists.
```
```python

14
index.html

@ -1431,15 +1431,15 @@ value = args.&lt;name&gt;
<li><strong>All exceptions are either 'OSError' or its subclasses.</strong></li>
</ul>
<pre><code class="python language-python hljs"><span class="hljs-keyword">import</span> os
os.chdir(&lt;path&gt;) <span class="hljs-comment"># Changes the current working directory.</span>
&lt;str&gt; = os.getcwd() <span class="hljs-comment"># Returns current working directory.</span>
os.chdir(&lt;path&gt;) <span class="hljs-comment"># Changes the current working directory.</span>
&lt;str&gt; = os.getcwd() <span class="hljs-comment"># Returns current working directory.</span>
</code></pre>
<pre><code class="python language-python hljs">os.remove(&lt;path&gt;) <span class="hljs-comment"># Deletes the file.</span>
os.rmdir(&lt;path&gt;) <span class="hljs-comment"># Deletes empty directory.</span>
shutil.rmtree(&lt;path&gt;) <span class="hljs-comment"># Deletes an entire directory tree.</span>
<pre><code class="python language-python hljs">os.remove(&lt;path&gt;) <span class="hljs-comment"># Deletes the file.</span>
os.rmdir(&lt;path&gt;) <span class="hljs-comment"># Deletes empty directory.</span>
shutil.rmtree(&lt;path&gt;) <span class="hljs-comment"># Deletes an entire directory tree.</span>
</code></pre>
<pre><code class="python language-python hljs">os.rename(<span class="hljs-keyword">from</span>, to) <span class="hljs-comment"># Renames the file or directory.</span>
os.replace(<span class="hljs-keyword">from</span>, to) <span class="hljs-comment"># Same, but overwrites 'to' if it exists.</span>
<pre><code class="python language-python hljs">os.rename(<span class="hljs-keyword">from</span>, to) <span class="hljs-comment"># Renames the file or directory.</span>
os.replace(<span class="hljs-keyword">from</span>, to) <span class="hljs-comment"># Same, but overwrites 'to' if it exists.</span>
</code></pre>
<pre><code class="python language-python hljs">os.mkdir(&lt;path&gt;, mode=<span class="hljs-number">0o777</span>) <span class="hljs-comment"># Creates a directory.</span>
&lt;iter&gt; = os.scandir(path=<span class="hljs-string">'.'</span>) <span class="hljs-comment"># Returns os.DirEntry objects located at path.</span>

Loading…
Cancel
Save