|
@ -436,11 +436,14 @@ to_exclusive = <range>.stop |
|
|
<str> = <str>.translate(<table>) <span class="hljs-comment"># Use `str.maketrans(<dict>)` to generate table.</span> |
|
|
<str> = <str>.translate(<table>) <span class="hljs-comment"># Use `str.maketrans(<dict>)` to generate table.</span> |
|
|
<list> = textwrap.wrap(<str>, width) <span class="hljs-comment"># Nicely breaks string into lines.</span> |
|
|
<list> = textwrap.wrap(<str>, width) <span class="hljs-comment"># Nicely breaks string into lines.</span> |
|
|
</code></pre> |
|
|
</code></pre> |
|
|
|
|
|
<pre><code class="python language-python hljs"><str> = chr(<int>) <span class="hljs-comment"># Converts int to unicode char.</span> |
|
|
|
|
|
<int> = ord(<str>) <span class="hljs-comment"># Converts unicode char to int.</span> |
|
|
|
|
|
</code></pre> |
|
|
<ul> |
|
|
<ul> |
|
|
<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> |
|
|
<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> |
|
|
<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> |
|
|
<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> |
|
|
</ul> |
|
|
</ul> |
|
|
<div><h3 id="properties">Properties</h3><pre><code class="text language-text">+---------------+----------+----------+----------+----------+----------+----------+ |
|
|
|
|
|
|
|
|
<div><h3 id="propertymethods">Property Methods</h3><pre><code class="text language-text">+---------------+----------+----------+----------+----------+----------+----------+ |
|
|
| | [\t\n\r] | [ !#$%…] | [A-Za-z] | [¼½¾…] | [¹²³…] | [0-9] | |
|
|
| | [\t\n\r] | [ !#$%…] | [A-Za-z] | [¼½¾…] | [¹²³…] | [0-9] | |
|
|
+---------------+----------+----------+----------+----------+----------+----------+ |
|
|
+---------------+----------+----------+----------+----------+----------+----------+ |
|
|
| isprintable() | | yes | yes | yes | yes | yes | |
|
|
| isprintable() | | yes | yes | yes | yes | yes | |
|
@ -451,10 +454,6 @@ to_exclusive = <range>.stop |
|
|
+---------------+----------+----------+----------+----------+----------+----------+ |
|
|
+---------------+----------+----------+----------+----------+----------+----------+ |
|
|
</code></pre></div> |
|
|
</code></pre></div> |
|
|
|
|
|
|
|
|
<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> |
|
|
|
|
|
<int> = ord(<str>) <span class="hljs-comment"># Converts unicode char to int.</span> |
|
|
|
|
|
</code></pre></div> |
|
|
|
|
|
|
|
|
|
|
|
<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 |
|
|
<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 |
|
|
<str> = re.sub(<regex>, new, text, count=<span class="hljs-number">0</span>) <span class="hljs-comment"># Substitutes all occurrences.</span> |
|
|
<str> = re.sub(<regex>, new, text, count=<span class="hljs-number">0</span>) <span class="hljs-comment"># Substitutes all occurrences.</span> |
|
|
<list> = re.findall(<regex>, text) <span class="hljs-comment"># Returns all occurrences.</span> |
|
|
<list> = re.findall(<regex>, text) <span class="hljs-comment"># Returns all occurrences.</span> |
|
|