|
1426 | 1426 | <li><strong>Use <code class="python hljs"><span class="hljs-string">'default=<el>'</span></code> to set the default value.</strong></li>
|
1427 | 1427 | <li><strong>Use <code class="python hljs"><span class="hljs-string">'type=FileType(<mode>)'</span></code> for files.</strong></li>
|
1428 | 1428 | </ul>
|
1429 |
| -<div><h2 id="open"><a href="#open" name="open">#</a>Open</h2><p><strong>Opens the file and returns a corresponding file object.</strong></p><pre><code class="python language-python hljs"><file> = open(<span class="hljs-string">'<path>'</span>, mode=<span class="hljs-string">'r'</span>, encoding=<span class="hljs-keyword">None</span>, newline=<span class="hljs-keyword">None</span>) |
| 1429 | +<div><h2 id="open"><a href="#open" name="open">#</a>Open</h2><p><strong>Opens the file and returns a corresponding file object.</strong></p><pre><code class="python language-python hljs"><file> = open(<path>, mode=<span class="hljs-string">'r'</span>, encoding=<span class="hljs-keyword">None</span>, newline=<span class="hljs-keyword">None</span>) |
1430 | 1430 | </code></pre></div>
|
1431 | 1431 |
|
1432 | 1432 |
|
|
1659 | 1659 | </code></pre></div>
|
1660 | 1660 |
|
1661 | 1661 | <div><h2 id="sqlite"><a href="#sqlite" name="sqlite">#</a>SQLite</h2><p><strong>Server-less database engine that stores each database into a separate file.</strong></p><div><h3 id="connect">Connect</h3><p><strong>Opens a connection to the database file. Creates a new file if path doesn't exist.</strong></p><pre><code class="python language-python hljs"><span class="hljs-keyword">import</span> sqlite3
|
1662 |
| -<con> = sqlite3.connect(<span class="hljs-string">'<path>'</span>) <span class="hljs-comment"># Also ':memory:'.</span> |
| 1662 | +<con> = sqlite3.connect(<path>) <span class="hljs-comment"># Also ':memory:'.</span> |
1663 | 1663 | <con>.close() <span class="hljs-comment"># Closes the connection.</span>
|
1664 | 1664 | </code></pre></div></div>
|
1665 | 1665 |
|
|
2049 | 2049 | pyplot.plot(<y_data> [, label=<str>])
|
2050 | 2050 | pyplot.plot(<x_data>, <y_data>)
|
2051 | 2051 | pyplot.legend() <span class="hljs-comment"># Adds a legend.</span>
|
2052 |
| -pyplot.savefig(<span class="hljs-string">'<path>'</span>) <span class="hljs-comment"># Saves the figure.</span> |
| 2052 | +pyplot.savefig(<path>) <span class="hljs-comment"># Saves the figure.</span> |
2053 | 2053 | pyplot.show() <span class="hljs-comment"># Displays the figure.</span>
|
2054 | 2054 | pyplot.clf() <span class="hljs-comment"># Clears the figure.</span>
|
2055 | 2055 | </code></pre></div>
|
|
2318 | 2318 | </code></pre></div>
|
2319 | 2319 |
|
2320 | 2320 | <pre><code class="python language-python hljs"><Image> = Image.new(<span class="hljs-string">'<mode>'</span>, (width, height))
|
2321 |
| -<Image> = Image.open(<span class="hljs-string">'<path>'</span>) |
| 2321 | +<Image> = Image.open(<path>) |
2322 | 2322 | <Image> = <Image>.convert(<span class="hljs-string">'<mode>'</span>)
|
2323 |
| -<Image>.save(<span class="hljs-string">'<path>'</span>) |
| 2323 | +<Image>.save(<path>) |
2324 | 2324 | <Image>.show()
|
2325 | 2325 | </code></pre>
|
2326 | 2326 | <pre><code class="python language-python hljs"><int/tuple> = <Image>.getpixel((x, y)) <span class="hljs-comment"># Returns a pixel.</span>
|
|
2531 | 2531 | <Surf>.set_at((x, y), color) <span class="hljs-comment"># Updates pixel.</span>
|
2532 | 2532 | <Surf>.blit(<Surface>, (x, y)) <span class="hljs-comment"># Draws passed surface to the surface.</span>
|
2533 | 2533 | </code></pre>
|
2534 |
| -<pre><code class="python language-python hljs"><Surf> = pg.transform.flip(<Surf>, xbool, ybool) |
| 2534 | +<pre><code class="python language-python hljs"><Surf> = pg.transform.scale(<Surf>, (width, height)) |
2535 | 2535 | <Surf> = pg.transform.rotate(<Surf>, degrees)
|
2536 |
| -<Surf> = pg.transform.scale(<Surf>, (width, height)) |
| 2536 | +<Surf> = pg.transform.flip(<Surf>, xbool, ybool) |
2537 | 2537 | </code></pre>
|
2538 | 2538 | <pre><code class="python language-python hljs">pg.draw.line(<Surf>, color, (x1, y1), (x2, y2), width)
|
2539 | 2539 | pg.draw.arc(<Surf>, color, <Rect>, from_radians, to_radians)
|
2540 | 2540 | pg.draw.rect(<Surf>, color, <Rect>)
|
2541 | 2541 | pg.draw.polygon(<Surf>, color, points)
|
2542 | 2542 | pg.draw.ellipse(<Surf>, color, <Rect>)
|
2543 | 2543 | </code></pre>
|
2544 |
| -<div><h3 id="font">Font</h3><pre><code class="python language-python hljs"><Font> = pg.font.SysFont(<span class="hljs-string">'<name>'</span>, size, bold=<span class="hljs-keyword">False</span>, italic=<span class="hljs-keyword">False</span>) |
2545 |
| -<Font> = pg.font.Font(<span class="hljs-string">'<path>'</span>, size) |
2546 |
| -<Surf> = <Font>.render(text, antialias, color [, background]) |
| 2544 | +<div><h3 id="font">Font</h3><pre><code class="python language-python hljs"><Font> = pg.font.SysFont(<span class="hljs-string">'<name>'</span>, size) <span class="hljs-comment"># Loads the system font or default if missing.</span> |
| 2545 | +<Font> = pg.font.Font(<span class="hljs-string">'<path>'</span>, size) <span class="hljs-comment"># Loads the TTF file. Pass None for default.</span> |
| 2546 | +<Surf> = <Font>.render(text, antialias, color) <span class="hljs-comment"># Background color can be specified at the end.</span> |
2547 | 2547 | </code></pre></div>
|
2548 | 2548 |
|
2549 | 2549 | <div><h3 id="sound">Sound</h3><pre><code class="python language-python hljs"><Sound> = pg.mixer.Sound(<span class="hljs-string">'<path>'</span>) <span class="hljs-comment"># Loads the WAV file.</span>
|
|
0 commit comments