-
Notifications
You must be signed in to change notification settings - Fork 0
/
Python.html
77 lines (75 loc) · 20 KB
/
Python.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- common.css -->
<style>* {-webkit-tap-highlight-color: rgba(0,0,0,0);}html {-webkit-text-size-adjust: none;}body {font-family: -apple-system, Helvetica, Arial, sans-serif;margin: 0;padding: 20px;color: #333;word-wrap: break-word;}h1, h2, h3, h4, h5, h6 {line-height: 1.1;}img {max-width: 100% !important;height: auto;}blockquote {margin: 0;padding: 0 15px;color: #777;border-left: 4px solid #ddd;}hr {background-color: #ddd;border: 0;height: 1px;margin: 15px 0;}code {font-family: Menlo, Consolas, 'Ubuntu Mono', Monaco, 'source-code-pro', monospace;line-height: 1.4;margin: 0;padding: 0.2em 0;font-size: 90%;background-color: rgba(0,0,0,0.04);border-radius: 3px;}pre > code {margin: 0;padding: 0;font-size: 100%;word-break: normal;background: transparent;border: 0;}ol {list-style-type: decimal;}ol ol, ul ol {list-style-type: lower-latin;}ol ol ol, ul ol ol, ul ul ol, ol ul ol {list-style-type: lower-roman;}table {border-spacing: 0;border-collapse: collapse;margin-top: 0;margin-bottom: 16px;}table th {font-weight: bold;}table th, table td {padding: 6px 13px;border: 1px solid #ddd;}table tr {border-top: 1px solid #ccc;}table tr:nth-child(even) {background-color: #f8f8f8;}input[type="checkbox"] {cursor: default;margin-right: 0.5em;font-size: 13px;}.task-list-item {list-style-type: none;}.task-list-item+.task-list-item {margin-top: 3px;}.task-list-item input {float: left;margin: 0.3em 1em 0.25em -1.6em;vertical-align: middle;}#tag-field {margin: 8px 2px 10px;}#tag-field .tag {display: inline-block;background: #cadff3;border-radius: 4px;padding: 1px 8px;color: black;font-size: 12px;margin-right: 10px;line-height: 1.4;}</style>
<!-- ace-static.css -->
<style>.ace_static_highlight {white-space: pre-wrap;}.ace_static_highlight .ace_gutter {width: 2em;text-align: right;padding: 0 3px 0 0;margin-right: 3px;}.ace_static_highlight.ace_show_gutter > .ace_line {padding-left: 2.6em;}.ace_static_highlight .ace_line {position: relative;}.ace_static_highlight .ace_gutter-cell {-moz-user-select: -moz-none;-khtml-user-select: none;-webkit-user-select: none;user-select: none;top: 0;bottom: 0;left: 0;position: absolute;}.ace_static_highlight .ace_gutter-cell:before {content: counter(ace_line, decimal);counter-increment: ace_line;}.ace_static_highlight {counter-reset: ace_line;}</style>
<style>.ace-chrome .ace_gutter {background: #ebebeb;color: #333;overflow : hidden;}.ace-chrome .ace_print-margin {width: 1px;background: #e8e8e8;}.ace-chrome {background-color: #FFFFFF;color: black;}.ace-chrome .ace_cursor {color: black;}.ace-chrome .ace_invisible {color: rgb(191, 191, 191);}.ace-chrome .ace_constant.ace_buildin {color: rgb(88, 72, 246);}.ace-chrome .ace_constant.ace_language {color: rgb(88, 92, 246);}.ace-chrome .ace_constant.ace_library {color: rgb(6, 150, 14);}.ace-chrome .ace_invalid {background-color: rgb(153, 0, 0);color: white;}.ace-chrome .ace_fold {}.ace-chrome .ace_support.ace_function {color: rgb(60, 76, 114);}.ace-chrome .ace_support.ace_constant {color: rgb(6, 150, 14);}.ace-chrome .ace_support.ace_type,.ace-chrome .ace_support.ace_class.ace-chrome .ace_support.ace_other {color: rgb(109, 121, 222);}.ace-chrome .ace_variable.ace_parameter {font-style:italic;color:#FD971F;}.ace-chrome .ace_keyword.ace_operator {color: rgb(104, 118, 135);}.ace-chrome .ace_comment {color: #236e24;}.ace-chrome .ace_comment.ace_doc {color: #236e24;}.ace-chrome .ace_comment.ace_doc.ace_tag {color: #236e24;}.ace-chrome .ace_constant.ace_numeric {color: rgb(0, 0, 205);}.ace-chrome .ace_variable {color: rgb(49, 132, 149);}.ace-chrome .ace_xml-pe {color: rgb(104, 104, 91);}.ace-chrome .ace_entity.ace_name.ace_function {color: #0000A2;}.ace-chrome .ace_heading {color: rgb(12, 7, 255);}.ace-chrome .ace_list {color:rgb(185, 6, 144);}.ace-chrome .ace_marker-layer .ace_selection {background: rgb(181, 213, 255);}.ace-chrome .ace_marker-layer .ace_step {background: rgb(252, 255, 0);}.ace-chrome .ace_marker-layer .ace_stack {background: rgb(164, 229, 101);}.ace-chrome .ace_marker-layer .ace_bracket {margin: -1px 0 0 -1px;border: 1px solid rgb(192, 192, 192);}.ace-chrome .ace_marker-layer .ace_active-line {background: rgba(0, 0, 0, 0.07);}.ace-chrome .ace_gutter-active-line {background-color : #dcdcdc;}.ace-chrome .ace_marker-layer .ace_selected-word {background: rgb(250, 250, 255);border: 1px solid rgb(200, 200, 250);}.ace-chrome .ace_storage,.ace-chrome .ace_keyword,.ace-chrome .ace_meta.ace_tag {color: rgb(147, 15, 128);}.ace-chrome .ace_string.ace_regex {color: rgb(255, 0, 0)}.ace-chrome .ace_string {color: #1A1AA6;}.ace-chrome .ace_entity.ace_other.ace_attribute-name {color: #994409;}.ace-chrome .ace_indent-guide {background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==") right repeat-y;}</style>
<!-- export.css -->
<style>
body{margin:0 auto;max-width:800px;line-height:1.4}
#nav{margin:5px 0 10px;font-size:15px}
#titlearea{border-bottom:1px solid #ccc;font-size:17px;padding:10px 0;}
#contentarea{font-size:15px;margin:16px 0}
.cell{outline:0;min-height:20px;margin:5px 0;padding:5px 0;}
.code-cell{font-family:Menlo,Consolas,'Ubuntu Mono',Monaco,'source-code-pro',monospace;font-size:12px;}
.latex-cell{white-space:pre-wrap;}
</style>
<!-- User CSS -->
<style> .text-cell {font-size: 15px;}.code-cell {font-size: 12px;}.markdown-cell {font-size: 15px;}.latex-cell {font-size: 15px;}</style>
</head>
<body>
<div id="nav"><div>Next: <a href='[P] K-Project.html'>[P] K-Project</a>, Up: <a href='index.html'>Index</a></div></div>
<div id="titlearea">
<h2>Python</h2>
</div>
<div id="contentarea"><div class="cell text-cell"></div><div class="cell text-cell"></div><div class="cell text-cell"></div><div class="cell text-cell"></div><div class="cell text-cell"></div><div class="cell text-cell"></div><div class="cell text-cell"></div><div class="cell text-cell"></div><div class="cell text-cell"></div><div class="cell text-cell"></div><div class="cell text-cell"></div><div class="cell text-cell"></div><div class="cell text-cell"></div><div class="cell text-cell"></div><div class="cell text-cell"></div><div class="cell text-cell"></div><div class="cell text-cell">Pip update all packages<div><pre style="font-family: Monaco, Consolas, monospace; font-size: 16px; margin: 0px -1rem 1rem; overflow-x: scroll; background-color: rgba(250, 250, 250, 0.701961); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; padding: 1rem; color: rgb(17, 17, 17); font-variant-ligatures: normal; orphans: 2; widows: 2;"><code class="prettyprint prettyprinted" style="font-family: Monaco, Consolas, monospace; font-size: 13px;"><span class="pln" style="color: rgb(0, 0, 0);">pip install </span><span class="pun" style="color: rgb(102, 102, 0);">-</span><span class="pln" style="color: rgb(0, 0, 0);">U $</span><span class="pun" style="color: rgb(102, 102, 0);">(</span><span class="pln" style="color: rgb(0, 0, 0);">pip freeze </span><span class="pun" style="color: rgb(102, 102, 0);">|</span><span class="pln" style="color: rgb(0, 0, 0);"> awk </span><span class="str" style="color: rgb(0, 136, 0);">'{split($0, a, "=="); print a[1]}'</span><span class="pun" style="color: rgb(102, 102, 0);">)</span></code></pre></div><div><code class="prettyprint prettyprinted" style="font-family: Monaco, Consolas, monospace; font-size: 13px;"><span class="pun" style="color: rgb(102, 102, 0);"><br></span></code></div></div><div class="cell text-cell"></div><div class="cell text-cell"><p style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; color: rgb(69, 69, 69);">Tips-Python</p>
<p style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; color: rgb(69, 69, 69); min-height: 14px;"><br></p>
<p style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; color: rgb(228, 175, 10);"><span style="text-decoration: underline"><a href="https://github.com/nschloe/pipdated">nschloe/pipdated: Python module for checking for updates on PyPi.</a></span></p>
<p style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; color: rgb(69, 69, 69); min-height: 14px;"><br></p>
<p style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; color: rgb(228, 175, 10);"><span style="font-stretch: normal; line-height: normal; font-family: ".PingFang SC"; text-decoration: underline;"><a href="http://pythonguidecn.readthedocs.io/zh/latest/dev/virtualenvs.html">虚拟环境<span style="font-stretch: normal; line-height: normal; font-family: "Helvetica Neue";"> — Python</span>最佳实践指南</a></span><span style="text-decoration: underline ; color: #454545"> virtualenv</span></p>
<p style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; color: rgb(69, 69, 69); min-height: 14px;"><br></p>
<p style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; color: rgb(69, 69, 69); min-height: 14px;"><br></p>
<p style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; color: rgb(69, 69, 69);">Curl http… > reddit.json</p>
<p style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; color: rgb(69, 69, 69);">More reddit.json</p>
<p style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; color: rgb(69, 69, 69);"><img src="resources/E1B2E9B7B2321B9DDCA2C631F67EAF7C.jpg" alt="Pasted Graphic 1.tiff" width="286" height="26"></p>
<p style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; color: rgb(69, 69, 69);">Like pretty()</p>
<p style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; color: rgb(69, 69, 69);"><img src="resources/1A1B6D86D457D21F537495A0A1CF83A4.jpg" alt="Pasted Graphic.tiff" width="222" height="166"></p>
<p style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; color: rgb(69, 69, 69); min-height: 14px;"><br></p>
<p style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; color: rgb(69, 69, 69);"><br></p>
<p style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; font-family: "Helvetica Neue"; color: rgb(69, 69, 69); min-height: 14px;"><br></p></div><div class="cell code-cell"><div class="ace-chrome"><div class="ace_static_highlight ace_show_gutter" style="counter-reset:ace_line 0"><div class="ace_line"><span class="ace_gutter ace_gutter-cell" unselectable="on"></span><span class="ace_keyword">for</span> <span class="ace_identifier">python</span> <span class="ace_constant ace_numeric">3</span>
</div><div class="ace_line"><span class="ace_gutter ace_gutter-cell" unselectable="on"></span><span class="ace_identifier">pip</span> <span class="ace_identifier">install</span> <span class="ace_identifier">bottle</span>
</div><div class="ace_line"><span class="ace_gutter ace_gutter-cell" unselectable="on"></span><span class="ace_identifier">For</span> <span class="ace_identifier">python</span> <span class="ace_constant ace_numeric">2</span>
</div><div class="ace_line"><span class="ace_gutter ace_gutter-cell" unselectable="on"></span><span class="ace_identifier">Sudo</span> <span class="ace_identifier">python</span> <span class="ace_keyword ace_operator">-</span><span class="ace_identifier">m</span> <span class="ace_identifier">easy_install</span> <span class="ace_identifier">bottle</span>
</div><div class="ace_line"><span class="ace_gutter ace_gutter-cell" unselectable="on"></span>
</div><div class="ace_line"><span class="ace_gutter ace_gutter-cell" unselectable="on"></span>
</div><div class="ace_line"><span class="ace_gutter ace_gutter-cell" unselectable="on"></span><span class="ace_identifier">Sudo</span> <span class="ace_identifier">python2</span><span class="ace_constant ace_numeric">.7</span> <span class="ace_keyword ace_operator">-</span><span class="ace_identifier">m</span> <span class="ace_identifier">pip</span> <span class="ace_identifier">install</span> <span class="ace_identifier">scipy</span>
</div><div class="ace_line"><span class="ace_gutter ace_gutter-cell" unselectable="on"></span><span class="ace_keyword ace_operator">//</span><span class="ace_keyword">if</span> <span class="ace_identifier">the</span> <span class="ace_identifier">eviroment</span> <span class="ace_identifier">already</span> <span class="ace_identifier">has</span> <span class="ace_identifier">the</span> <span class="ace_identifier">python</span> <span class="ace_constant ace_numeric">2</span> <span class="ace_keyword">and</span> <span class="ace_identifier">python</span> <span class="ace_constant ace_numeric">3</span>, <span class="ace_identifier">use</span> <span class="ace_identifier">this</span> <span class="ace_identifier">command</span> <span class="ace_identifier">to</span> <span class="ace_identifier">install</span> <span class="ace_identifier">the</span> <span class="ace_identifier">package</span>
</div><div class="ace_line"><span class="ace_gutter ace_gutter-cell" unselectable="on"></span>
</div><div class="ace_line"><span class="ace_gutter ace_gutter-cell" unselectable="on"></span><span class="ace_identifier">py</span> <span class="ace_keyword ace_operator">-</span><span class="ace_constant ace_numeric">2.7</span>
</div><div class="ace_line"><span class="ace_gutter ace_gutter-cell" unselectable="on"></span>
</div><div class="ace_line"><span class="ace_gutter ace_gutter-cell" unselectable="on"></span><span class="ace_identifier">Upgrade</span> <span class="ace_identifier">python2</span> <span class="ace_identifier">package</span>
</div><div class="ace_line"><span class="ace_gutter ace_gutter-cell" unselectable="on"></span><span class="ace_identifier">sudo</span> <span class="ace_identifier">python2</span><span class="ace_constant ace_numeric">.7</span> <span class="ace_keyword ace_operator">-</span><span class="ace_identifier">m</span> <span class="ace_identifier">pip</span> <span class="ace_identifier">install</span> <span class="ace_keyword ace_operator">--</span><span class="ace_identifier">upgrade</span> <span class="ace_identifier">numpy</span>
</div><div class="ace_line"><span class="ace_gutter ace_gutter-cell" unselectable="on"></span>
</div><div class="ace_line"><span class="ace_gutter ace_gutter-cell" unselectable="on"></span><span class="ace_identifier">pip2</span> <span class="ace_identifier">freeze</span> <span class="ace_keyword ace_operator">--</span><span class="ace_identifier">local</span> <span class="ace_keyword ace_operator">|</span> <span class="ace_identifier">grep</span> <span class="ace_keyword ace_operator">-</span><span class="ace_identifier">v</span> <span class="ace_string">'^\-e'</span> <span class="ace_keyword ace_operator">|</span> <span class="ace_identifier">cut</span> <span class="ace_keyword ace_operator">-</span><span class="ace_identifier">d</span> <span class="ace_keyword ace_operator">=</span> <span class="ace_keyword ace_operator">-</span><span class="ace_identifier">f</span> <span class="ace_constant ace_numeric">1</span> <span class="ace_keyword ace_operator">|</span> <span class="ace_identifier">xargs</span> <span class="ace_identifier">pip2</span> <span class="ace_identifier">install</span> <span class="ace_keyword ace_operator">-</span><span class="ace_identifier">U</span>
</div><div class="ace_line"><span class="ace_gutter ace_gutter-cell" unselectable="on"></span>
</div><div class="ace_line"><span class="ace_gutter ace_gutter-cell" unselectable="on"></span>
</div><div class="ace_line"><span class="ace_gutter ace_gutter-cell" unselectable="on"></span><span class="ace_comment"># Use Homebrew :)</span>
</div><div class="ace_line"><span class="ace_gutter ace_gutter-cell" unselectable="on"></span><span class="ace_identifier">brew</span> <span class="ace_identifier">install</span> <span class="ace_identifier">python3</span>
</div><div class="ace_line"><span class="ace_gutter ace_gutter-cell" unselectable="on"></span><span class="ace_comment"># To update it:</span>
</div><div class="ace_line"><span class="ace_gutter ace_gutter-cell" unselectable="on"></span><span class="ace_identifier">brew</span> <span class="ace_identifier">update</span>
</div><div class="ace_line"><span class="ace_gutter ace_gutter-cell" unselectable="on"></span><span class="ace_identifier">brew</span> <span class="ace_identifier">upgrade</span> <span class="ace_identifier">python3</span>
</div></div></div></div><div class="cell text-cell"></div><div class="cell text-cell">##读取json文件并转换为字典</div><div class="cell code-cell"><div class="ace-chrome"><div class="ace_static_highlight ace_show_gutter" style="counter-reset:ace_line 0"><div class="ace_line"><span class="ace_gutter ace_gutter-cell" unselectable="on"></span><span class="ace_comment"># -*- coding:utf-8 -*-</span>
</div><div class="ace_line"><span class="ace_gutter ace_gutter-cell" unselectable="on"></span><span class="ace_keyword">import</span> <span class="ace_identifier">json</span>
</div><div class="ace_line"><span class="ace_gutter ace_gutter-cell" unselectable="on"></span><span class="ace_identifier">file_path</span> <span class="ace_keyword ace_operator">=</span> <span class="ace_string">'json<span class="ace_cjk" style="width:NaNpx">文</span><span class="ace_cjk" style="width:NaNpx">件</span><span class="ace_cjk" style="width:NaNpx">相</span><span class="ace_cjk" style="width:NaNpx">对</span><span class="ace_cjk" style="width:NaNpx">路</span><span class="ace_cjk" style="width:NaNpx">径</span><span class="ace_cjk" style="width:NaNpx">或</span><span class="ace_cjk" style="width:NaNpx">者</span><span class="ace_cjk" style="width:NaNpx">据</span><span class="ace_cjk" style="width:NaNpx">对</span><span class="ace_cjk" style="width:NaNpx">路</span><span class="ace_cjk" style="width:NaNpx">径</span>'</span>
</div><div class="ace_line"><span class="ace_gutter ace_gutter-cell" unselectable="on"></span><span class="ace_keyword">with</span> <span class="ace_support ace_function">open</span><span class="ace_paren ace_lparen">(</span><span class="ace_identifier">file_path</span><span class="ace_paren ace_rparen">)</span> <span class="ace_keyword">as</span> <span class="ace_identifier">f</span>:
</div><div class="ace_line"><span class="ace_gutter ace_gutter-cell" unselectable="on"></span> <span class="ace_identifier">js</span> <span class="ace_keyword ace_operator">=</span> <span class="ace_identifier">json</span>.<span class="ace_identifier">load</span><span class="ace_paren ace_lparen">(</span><span class="ace_identifier">f</span><span class="ace_paren ace_rparen">)</span> <span class="ace_comment"># js<span class="ace_cjk" style="width:NaNpx">是</span><span class="ace_cjk" style="width:NaNpx">转</span><span class="ace_cjk" style="width:NaNpx">换</span><span class="ace_cjk" style="width:NaNpx">后</span><span class="ace_cjk" style="width:NaNpx">的</span><span class="ace_cjk" style="width:NaNpx">字</span><span class="ace_cjk" style="width:NaNpx">典</span></span>
</div></div></div></div><div class="cell text-cell"></div><div class="cell text-cell"></div><div class="cell text-cell"></div><div class="cell text-cell"></div><div class="cell text-cell"></div><div class="cell text-cell"></div><div class="cell text-cell"></div><div class="cell text-cell"></div><div class="cell text-cell"></div><div class="cell text-cell"></div></div>
<script>document.body.onkeyup = function(e) {
if (e.keyCode === 39) window.location.href = '[P] K-Project.html';
}</script>
</body>
</html>