|
1913 | 1913 |
|
1914 | 1914 | <div><h2 id="plot"><a href="#plot" name="plot">#</a>Plot</h2><pre><code class="python language-python hljs"><span class="hljs-comment"># $ pip3 install matplotlib</span>
|
1915 | 1915 | <span class="hljs-keyword">from</span> matplotlib <span class="hljs-keyword">import</span> pyplot
|
1916 |
| -pyplot.plot(<data_1> [, <data_2>, ...]) <span class="hljs-comment"># Or: hist(<data>).</span> |
| 1916 | +pyplot.plot(<data_1> [, <data_2>, ...]) <span class="hljs-comment"># Or: pyplot.hist(<data>)</span> |
1917 | 1917 | pyplot.savefig(<filename>)
|
1918 | 1918 | pyplot.show()
|
1919 | 1919 | pyplot.clf() <span class="hljs-comment"># Clears figure.</span>
|
|
1923 | 1923 | <span class="hljs-keyword">from</span> tabulate <span class="hljs-keyword">import</span> tabulate
|
1924 | 1924 | <span class="hljs-keyword">import</span> csv
|
1925 | 1925 | <span class="hljs-keyword">with</span> open(<filename>, encoding=<span class="hljs-string">'utf-8'</span>, newline=<span class="hljs-string">''</span>) <span class="hljs-keyword">as</span> file:
|
1926 |
| - lines = csv.reader(file) |
1927 |
| - headers = [header.title() <span class="hljs-keyword">for</span> header <span class="hljs-keyword">in</span> next(lines)] |
1928 |
| - table = tabulate(lines, headers) |
| 1926 | + rows = csv.reader(file) |
| 1927 | + header = [a.title() <span class="hljs-keyword">for</span> a <span class="hljs-keyword">in</span> next(rows)] |
| 1928 | + table = tabulate(rows, header) |
1929 | 1929 | print(table)
|
1930 | 1930 | </code></pre></div></div>
|
1931 | 1931 |
|
|
1962 | 1962 | <ul>
|
1963 | 1963 | <li><strong>Levels: <code class="python hljs"><span class="hljs-string">'debug'</span></code>, <code class="python hljs"><span class="hljs-string">'info'</span></code>, <code class="python hljs"><span class="hljs-string">'success'</span></code>, <code class="python hljs"><span class="hljs-string">'warning'</span></code>, <code class="python hljs"><span class="hljs-string">'error'</span></code>, <code class="python hljs"><span class="hljs-string">'critical'</span></code>.</strong></li>
|
1964 | 1964 | </ul>
|
1965 |
| -<div><h3 id="exceptions-2">Exceptions</h3><p><strong>Error description, stack trace and values of variables are appended automatically.</strong></p><pre><code class="python language-python hljs"><span class="hljs-keyword">try</span>: |
| 1965 | +<div><h3 id="exceptions-2">Exceptions</h3><p><strong>Exception description, stack trace and values of variables are appended automatically.</strong></p><pre><code class="python language-python hljs"><span class="hljs-keyword">try</span>: |
1966 | 1966 | ...
|
1967 | 1967 | <span class="hljs-keyword">except</span> <exception>:
|
1968 | 1968 | logger.exception(<span class="hljs-string">'An error happened.'</span>)
|
|
2044 | 2044 | </code></pre></div>
|
2045 | 2045 |
|
2046 | 2046 | <div><h2 id="profile"><a href="#profile" name="profile">#</a>Profile</h2><div><h3 id="basic">Basic</h3><pre><code class="python language-python hljs"><span class="hljs-keyword">from</span> time <span class="hljs-keyword">import</span> time
|
2047 |
| -start_time = time() <span class="hljs-comment"># Seconds since Epoch.</span> |
| 2047 | +start_time = time() <span class="hljs-comment"># Seconds since the Epoch.</span> |
2048 | 2048 | ...
|
2049 | 2049 | duration = time() - start_time
|
2050 | 2050 | </code></pre></div></div>
|
|
0 commit comments