|
436 | 436 | <str> = <str>.translate(<table>) <span class="hljs-comment"># Use `str.maketrans(<dict>)` to generate table.</span>
|
437 | 437 | <list> = textwrap.wrap(<str>, width) <span class="hljs-comment"># Nicely breaks string into lines.</span>
|
438 | 438 | </code></pre>
|
| 439 | +<pre><code class="python language-python hljs"><str> = chr(<int>) <span class="hljs-comment"># Converts int to unicode char.</span> |
| 440 | +<int> = ord(<str>) <span class="hljs-comment"># Converts unicode char to int.</span> |
| 441 | +</code></pre> |
439 | 442 | <ul>
|
440 | 443 | <li><strong>Also: <code class="python hljs"><span class="hljs-string">'lstrip()'</span></code>, <code class="python hljs"><span class="hljs-string">'rstrip()'</span></code>.</strong></li>
|
441 | 444 | <li><strong>Also: <code class="python hljs"><span class="hljs-string">'lower()'</span></code>, <code class="python hljs"><span class="hljs-string">'upper()'</span></code>, <code class="python hljs"><span class="hljs-string">'capitalize()'</span></code> and <code class="python hljs"><span class="hljs-string">'title()'</span></code>.</strong></li>
|
442 | 445 | </ul>
|
443 |
| -<div><h3 id="properties">Properties</h3><pre><code class="text language-text">+---------------+----------+----------+----------+----------+----------+----------+ |
| 446 | +<div><h3 id="propertymethods">Property Methods</h3><pre><code class="text language-text">+---------------+----------+----------+----------+----------+----------+----------+ |
444 | 447 | | | [\t\n\r] | [ !#$%…] | [A-Za-z] | [¼½¾…] | [¹²³…] | [0-9] |
|
445 | 448 | +---------------+----------+----------+----------+----------+----------+----------+
|
446 | 449 | | isprintable() | | yes | yes | yes | yes | yes |
|
|
451 | 454 | +---------------+----------+----------+----------+----------+----------+----------+
|
452 | 455 | </code></pre></div>
|
453 | 456 |
|
454 |
| -<div><h3 id="char">Char</h3><pre><code class="python language-python hljs"><str> = chr(<int>) <span class="hljs-comment"># Converts int to unicode char.</span> |
455 |
| -<int> = ord(<str>) <span class="hljs-comment"># Converts unicode char to int.</span> |
456 |
| -</code></pre></div> |
457 |
| - |
458 | 457 | <div><h2 id="regex"><a href="#regex" name="regex">#</a>Regex</h2><pre><code class="python language-python hljs"><span class="hljs-keyword">import</span> re
|
459 | 458 | <str> = re.sub(<regex>, new, text, count=<span class="hljs-number">0</span>) <span class="hljs-comment"># Substitutes all occurrences.</span>
|
460 | 459 | <list> = re.findall(<regex>, text) <span class="hljs-comment"># Returns all occurrences.</span>
|
|
0 commit comments