Browse Source

Format

pull/152/head
Jure Šorn 1 year ago
parent
commit
c7c1fec8fa
2 changed files with 2 additions and 2 deletions
  1. 2
      README.md
  2. 2
      index.html

2
README.md

@ -390,7 +390,7 @@ import re
Format
------
```python
```bash
<str> = f'{<el_1>}, {<el_2>}' # Curly brackets can also contain expressions.
<str> = '{}, {}'.format(<el_1>, <el_2>) # Or: '{0}, {a}'.format(<el_1>, a=<el_2>)
<str> = '%s, %s' % (<el_1>, <el_2>) # Redundant and inferior C-style formatting.

2
index.html

@ -364,7 +364,7 @@ Point(x=<span class="hljs-number">1</span>, y=<span class="hljs-number">2</span>
<li><strong>As shown above, it restricts all special sequence matches to the first 128 characters and prevents <code class="python hljs"><span class="hljs-string">'\s'</span></code> from accepting <code class="python hljs"><span class="hljs-string">'[\x1c-\x1f]'</span></code> (the so-called separator characters).</strong></li>
<li><strong>Use a capital letter for negation (all non-ASCII characters will be matched when used in combination with ASCII flag).</strong></li>
</ul>
<div><h2 id="format"><a href="#format" name="format">#</a>Format</h2><pre><code class="python language-python hljs">&lt;str&gt; = <span class="hljs-string">f'<span class="hljs-subst">{&lt;el_1&gt;}</span>, <span class="hljs-subst">{&lt;el_2&gt;}</span>'</span> <span class="hljs-comment"># Curly brackets can also contain expressions.</span>
<div><h2 id="format"><a href="#format" name="format">#</a>Format</h2><pre><code class="bash language-bash hljs">&lt;str&gt; = f<span class="hljs-string">'{&lt;el_1&gt;}, {&lt;el_2&gt;}'</span> <span class="hljs-comment"># Curly brackets can also contain expressions.</span>
&lt;str&gt; = <span class="hljs-string">'{}, {}'</span>.format(&lt;el_1&gt;, &lt;el_2&gt;) <span class="hljs-comment"># Or: '{0}, {a}'.format(&lt;el_1&gt;, a=&lt;el_2&gt;)</span>
&lt;str&gt; = <span class="hljs-string">'%s, %s'</span> % (&lt;el_1&gt;, &lt;el_2&gt;) <span class="hljs-comment"># Redundant and inferior C-style formatting.</span>
</code></pre></div>

Loading…
Cancel
Save