| 
426 | 426 | 
 
  | 
427 | 427 | <pre><code class="python language-python hljs"><list> = <str>.split()                       <span class="hljs-comment"># Splits on one or more whitespace characters.</span>  | 
428 | 428 | <list> = <str>.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 |  | -<list> = <str>.splitlines(keepends=<span class="hljs-keyword">False</span>)    <span class="hljs-comment"># Splits on line breaks. Keeps them if 'keepends'.</span>  | 
 | 429 | +<list> = <str>.splitlines(keepends=<span class="hljs-keyword">False</span>)    <span class="hljs-comment"># Splits on \n,\r,\r\n. Keeps them if 'keepends'.</span>  | 
430 | 430 | <str>  = <str>.join(<coll_of_strings>)       <span class="hljs-comment"># Joins elements using string as separator.</span>  | 
431 | 431 | </code></pre>  | 
432 | 432 | <pre><code class="python language-python hljs"><bool> = <sub_str> <span class="hljs-keyword">in</span> <str>                  <span class="hljs-comment"># Checks if string contains a substring.</span>  | 
 | 
1526 | 1526 | <pre><code class="python language-python hljs">os.chdir(<path>)                    <span class="hljs-comment"># Changes current working directory.</span>  | 
1527 | 1527 | os.mkdir(<path>, mode=<span class="hljs-number">0o777</span>)        <span class="hljs-comment"># Creates a directory. Mode is in octal.</span>  | 
1528 | 1528 | </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>  | 
1531 | 1531 | </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>  | 
1533 | 1533 | os.replace(from, to)                <span class="hljs-comment"># Same, but overwrites 'to' if it exists.</span>  | 
1534 | 1534 | </code></pre>  | 
1535 | 1535 | <pre><code class="python language-python hljs">os.remove(<path>)                   <span class="hljs-comment"># Deletes the file.</span>  | 
1536 | 1536 | os.rmdir(<path>)                    <span class="hljs-comment"># Deletes the empty directory.</span>  | 
1537 |  | -shutil.rmtree(<path>)               <span class="hljs-comment"># Deletes the non-empty directory.</span>  | 
 | 1537 | +shutil.rmtree(<path>)               <span class="hljs-comment"># Deletes the directory.</span>  | 
1538 | 1538 | </code></pre>  | 
1539 | 1539 | <div><h3 id="shellcommands">Shell Commands</h3><pre><code class="python language-python hljs"><span class="hljs-keyword">import</span> os  | 
1540 | 1540 | <str> = os.popen(<span class="hljs-string">'<shell_command>'</span>).read()  | 
 | 
0 commit comments