Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 73f553f

Browse files
committed
String, os commands
1 parent abeffbe commit 73f553f

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ String
309309
```python
310310
<list> = <str>.split() # Splits on one or more whitespace characters.
311311
<list> = <str>.split(sep=None, maxsplit=-1) # Splits on 'sep' str at most 'maxsplit' times.
312-
<list> = <str>.splitlines(keepends=False) # Splits on line breaks. Keeps them if 'keepends'.
312+
<list> = <str>.splitlines(keepends=False) # Splits on \n,\r,\r\n. Keeps them if 'keepends'.
313313
<str> = <str>.join(<coll_of_strings>) # Joins elements using string as separator.
314314
```
315315

@@ -1676,19 +1676,19 @@ os.mkdir(<path>, mode=0o777) # Creates a directory. Mode is in octal.
16761676
```
16771677

16781678
```python
1679-
shutil.copy(from, to) # Copies the file.
1680-
shutil.copytree(from, to) # Copies the directory.
1679+
shutil.copy(from, to) # Copies the file. 'to' can be a directory.
1680+
shutil.copytree(from, to) # Copies the directory. 'to' must not exist.
16811681
```
16821682

16831683
```python
1684-
os.rename(from, to) # Renames or moves the file or directory.
1684+
os.rename(from, to) # Renames/moves the file or directory.
16851685
os.replace(from, to) # Same, but overwrites 'to' if it exists.
16861686
```
16871687

16881688
```python
16891689
os.remove(<path>) # Deletes the file.
16901690
os.rmdir(<path>) # Deletes the empty directory.
1691-
shutil.rmtree(<path>) # Deletes the non-empty directory.
1691+
shutil.rmtree(<path>) # Deletes the directory.
16921692
```
16931693

16941694
### Shell Commands

index.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@
426426

427427
<pre><code class="python language-python hljs">&lt;list&gt; = &lt;str&gt;.split() <span class="hljs-comment"># Splits on one or more whitespace characters.</span>
428428
&lt;list&gt; = &lt;str&gt;.split(sep=<span class="hljs-keyword">None</span>, maxsplit=<span class="hljs-number">-1</span>) <span class="hljs-comment"># Splits on 'sep' str at most 'maxsplit' times.</span>
429-
&lt;list&gt; = &lt;str&gt;.splitlines(keepends=<span class="hljs-keyword">False</span>) <span class="hljs-comment"># Splits on line breaks. Keeps them if 'keepends'.</span>
429+
&lt;list&gt; = &lt;str&gt;.splitlines(keepends=<span class="hljs-keyword">False</span>) <span class="hljs-comment"># Splits on \n,\r,\r\n. Keeps them if 'keepends'.</span>
430430
&lt;str&gt; = &lt;str&gt;.join(&lt;coll_of_strings&gt;) <span class="hljs-comment"># Joins elements using string as separator.</span>
431431
</code></pre>
432432
<pre><code class="python language-python hljs">&lt;bool&gt; = &lt;sub_str&gt; <span class="hljs-keyword">in</span> &lt;str&gt; <span class="hljs-comment"># Checks if string contains a substring.</span>
@@ -1526,15 +1526,15 @@
15261526
<pre><code class="python language-python hljs">os.chdir(&lt;path&gt;) <span class="hljs-comment"># Changes current working directory.</span>
15271527
os.mkdir(&lt;path&gt;, mode=<span class="hljs-number">0o777</span>) <span class="hljs-comment"># Creates a directory. Mode is in octal.</span>
15281528
</code></pre>
1529-
<pre><code class="python language-python hljs">shutil.copy(from, to) <span class="hljs-comment"># Copies the file.</span>
1530-
shutil.copytree(from, to) <span class="hljs-comment"># Copies the directory.</span>
1529+
<pre><code class="python language-python hljs">shutil.copy(from, to) <span class="hljs-comment"># Copies the file. 'to' can be a directory.</span>
1530+
shutil.copytree(from, to) <span class="hljs-comment"># Copies the directory. 'to' must not exist.</span>
15311531
</code></pre>
1532-
<pre><code class="python language-python hljs">os.rename(from, to) <span class="hljs-comment"># Renames or moves the file or directory.</span>
1532+
<pre><code class="python language-python hljs">os.rename(from, to) <span class="hljs-comment"># Renames/moves the file or directory.</span>
15331533
os.replace(from, to) <span class="hljs-comment"># Same, but overwrites 'to' if it exists.</span>
15341534
</code></pre>
15351535
<pre><code class="python language-python hljs">os.remove(&lt;path&gt;) <span class="hljs-comment"># Deletes the file.</span>
15361536
os.rmdir(&lt;path&gt;) <span class="hljs-comment"># Deletes the empty directory.</span>
1537-
shutil.rmtree(&lt;path&gt;) <span class="hljs-comment"># Deletes the non-empty directory.</span>
1537+
shutil.rmtree(&lt;path&gt;) <span class="hljs-comment"># Deletes the directory.</span>
15381538
</code></pre>
15391539
<div><h3 id="shellcommands">Shell Commands</h3><pre><code class="python language-python hljs"><span class="hljs-keyword">import</span> os
15401540
&lt;str&gt; = os.popen(<span class="hljs-string">'&lt;shell_command&gt;'</span>).read()

parse.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ const TOC =
3434
'</code></pre>\n';
3535

3636
const OS_RENAME =
37-
'os.rename(from, to) <span class="hljs-comment"># Renames or moves the file or directory.</span>\n' +
37+
'os.rename(from, to) <span class="hljs-comment"># Renames/moves the file or directory.</span>\n' +
3838
'os.replace(from, to) <span class="hljs-comment"># Same, but overwrites \'to\' if it exists.</span>\n';
3939

4040
const SHUTIL_COPY =
41-
'shutil.copy(from, to) <span class="hljs-comment"># Copies the file.</span>\n' +
42-
'shutil.copytree(from, to) <span class="hljs-comment"># Copies the directory.</span>\n';
41+
'shutil.copy(from, to) <span class="hljs-comment"># Copies the file. \'to\' can be a directory.</span>\n' +
42+
'shutil.copytree(from, to) <span class="hljs-comment"># Copies the directory. \'to\' must not exist.</span>\n';
4343

4444
const EVAL =
4545
'<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> ast <span class="hljs-keyword">import</span> literal_eval\n' +

0 commit comments

Comments
 (0)