Browse Source

Command execution

pull/40/head
Jure Šorn 5 years ago
parent
commit
23c6c41432
2 changed files with 24 additions and 24 deletions
  1. 24
      README.md
  2. 24
      index.html

24
README.md

@ -1597,31 +1597,31 @@ Command Execution
```python
import os
os.chdir(<path>) # Changes the current working directory.
<str> = os.getcwd() # Returns current working directory.
<str> = os.getcwd() # Returns the current working directory.
os.chdir(<path>) # Changes the 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 the 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
os.mkdir(<path>, mode=0o777) # Creates a directory.
<iter> = os.scandir(path='.') # Returns os.DirEntry objects located at path.
os.mkdir(<path>, mode=0o777) # Creates a directory.
<iter> = os.scandir(path='.') # Returns os.DirEntry objects located at path.
```
#### DirEntry:
```python
<str> = <DirEntry>.name # Final component of the path.
<str> = <DirEntry>.path # Path with final component.
<Path> = Path(<DirEntry>) # Path object.
<str> = <DirEntry>.name # Final component of the path.
<str> = <DirEntry>.path # Path with final component.
<Path> = Path(<DirEntry>) # Path object.
```
```python

24
index.html

@ -1437,23 +1437,23 @@ 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>
&lt;str&gt; = os.getcwd() <span class="hljs-comment"># Returns the current working directory.</span>
os.chdir(&lt;path&gt;) <span class="hljs-comment"># Changes the 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 the 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>
<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>
</code></pre>
<h4 id="direntry">DirEntry:</h4>
<pre><code class="python language-python hljs">&lt;str&gt; = &lt;DirEntry&gt;.name <span class="hljs-comment"># Final component of the path.</span>
&lt;str&gt; = &lt;DirEntry&gt;.path <span class="hljs-comment"># Path with final component.</span>
&lt;Path&gt; = Path(&lt;DirEntry&gt;) <span class="hljs-comment"># Path object.</span>
<pre><code class="python language-python hljs">&lt;str&gt; = &lt;DirEntry&gt;.name <span class="hljs-comment"># Final component of the path.</span>
&lt;str&gt; = &lt;DirEntry&gt;.path <span class="hljs-comment"># Path with final component.</span>
&lt;Path&gt; = Path(&lt;DirEntry&gt;) <span class="hljs-comment"># Path object.</span>
</code></pre>
<pre><code class="python language-python hljs">&lt;bool&gt; = &lt;DirEntry&gt;.is_file()
&lt;bool&gt; = &lt;DirEntry&gt;.is_dir()

Loading…
Cancel
Save