Skip to content

Commit

Permalink
new posts python-learning-#00-#1
Browse files Browse the repository at this point in the history
  • Loading branch information
mikelyou committed Jan 2, 2020
1 parent 889eb85 commit 8531ca3
Show file tree
Hide file tree
Showing 16 changed files with 1,133 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
I"�<h2 id="注释">注释</h2>

<p>单行注释 - 以#和空格开头的部分
多行注释 - 三个引号开头,三个引号结尾 (单引号与双引号仅有微小区别,可以忽略)</p>

<h4 id="单行注释">单行注释</h4>
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
</pre></td><td class="rouge-code"><pre><span class="n">a</span> <span class="o">=</span> <span class="n">b</span> <span class="o">+</span> <span class="n">c</span> <span class="c1"># 这是一条注释
</span></pre></td></tr></tbody></table></code></pre></div></div>
<h4 id="多行注释">多行注释</h4>
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
3
4
5
6
</pre></td><td class="rouge-code"><pre><span class="k">print</span><span class="p">(</span><span class="s">"下面是多行注释"</span><span class="p">)</span>
<span class="s">"""
print("注释")
print("注释不会编译")
print("可以看到print的字体颜色改变了")
"""</span>
</pre></td></tr></tbody></table></code></pre></div></div>

<h2 id="数据类型">数据类型</h2>

<h4 id="常用数据类型">常用数据类型:</h4>

<ul>
<li>整形 int</li>
<li>浮点型 float</li>
<li>字符串型 ‘hello’ or “hello” (单引号与双引号仅有微小区别,可以忽略)</li>
<li>布尔型 True or False</li>
</ul>

<h4 id="变量">变量</h4>

<ul>
<li>变量命名:建议采用 <strong>全小写加下划线</strong> 的拼写,不能以数字开头,大小写敏感,见名识义。</li>
<li>使用<code class="highlighter-rouge">type</code>函数检查变量的类型
<pre><code class="language-Python">a = 100
b = 12.345
c = 1 + 5j
d = 'hello, world'
e = True
print(type(a)) # &lt;class 'int'&gt;
print(type(b)) # &lt;class 'float'&gt;
print(type(c)) # &lt;class 'complex'&gt;
print(type(d)) # &lt;class 'str'&gt;
print(type(e)) # &lt;class 'bool'&gt;
</code></pre>
</li>
<li>使用Python内置函数转换变量类型</li>
<li><code class="highlighter-rouge">int()</code>:将一个数值或字符串转换成整数,可以指定进制。</li>
<li><code class="highlighter-rouge">float()</code>:将一个字符串转换成浮点数。</li>
<li><code class="highlighter-rouge">str()</code>:将指定的对象转换成字符串形式,可以指定编码。</li>
<li><code class="highlighter-rouge">chr()</code>:将整数转换成该编码对应的字符串(一个字符)。</li>
<li><code class="highlighter-rouge">ord()</code>:将字符串(一个字符)转换成对应的编码(整数)。</li>
</ul>

<h4 id="运算符">运算符</h4>

<table>
<thead>
<tr>
<th>运算符</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td><code class="highlighter-rouge">[]</code> <code class="highlighter-rouge">[:]</code></td>
<td>下标,切片</td>
</tr>
<tr>
<td><code class="highlighter-rouge">**</code></td>
<td>指数</td>
</tr>
<tr>
<td><code class="highlighter-rouge">~</code> <code class="highlighter-rouge">+</code> <code class="highlighter-rouge">-</code></td>
<td>按位取反, 正负号</td>
</tr>
<tr>
<td><code class="highlighter-rouge">*</code> <code class="highlighter-rouge">/</code> <code class="highlighter-rouge">%</code> <code class="highlighter-rouge">//</code></td>
<td>乘,除,模,整除</td>
</tr>
<tr>
<td><code class="highlighter-rouge">+</code> <code class="highlighter-rouge">-</code></td>
<td>加,减</td>
</tr>
<tr>
<td><code class="highlighter-rouge">&gt;&gt;</code> <code class="highlighter-rouge">&lt;&lt;</code></td>
<td>右移,左移</td>
</tr>
<tr>
<td><code class="highlighter-rouge">&amp;</code></td>
<td>按位与</td>
</tr>
<tr>
<td><code class="highlighter-rouge">^</code> <code class="highlighter-rouge">\|</code></td>
<td>按位异或,按位或</td>
</tr>
<tr>
<td><code class="highlighter-rouge">&lt;=</code> <code class="highlighter-rouge">&lt;</code> <code class="highlighter-rouge">&gt;</code> <code class="highlighter-rouge">&gt;=</code></td>
<td>小于等于,小于,大于,大于等于</td>
</tr>
<tr>
<td><code class="highlighter-rouge">==</code> <code class="highlighter-rouge">!=</code></td>
<td>等于,不等于</td>
</tr>
<tr>
<td><code class="highlighter-rouge">is</code> <code class="highlighter-rouge">is not</code></td>
<td>身份运算符</td>
</tr>
<tr>
<td><code class="highlighter-rouge">in</code> <code class="highlighter-rouge">not in</code></td>
<td>成员运算符</td>
</tr>
<tr>
<td><code class="highlighter-rouge">not</code> <code class="highlighter-rouge">or</code> <code class="highlighter-rouge">and</code></td>
<td>逻辑运算符</td>
</tr>
<tr>
<td><code class="highlighter-rouge">=</code> <code class="highlighter-rouge">+=</code> <code class="highlighter-rouge">-=</code> <code class="highlighter-rouge">*=</code> <code class="highlighter-rouge">/=</code> <code class="highlighter-rouge">%=</code> <code class="highlighter-rouge">//=</code> <code class="highlighter-rouge">**=</code> <code class="highlighter-rouge">&amp;=</code> <code class="highlighter-rouge">|=</code> <code class="highlighter-rouge">^=</code> <code class="highlighter-rouge">&gt;&gt;=</code> <code class="highlighter-rouge">&lt;&lt;=</code></td>
<td>(复合)赋值运算符</td>
</tr>
</tbody>
</table>

<blockquote>
<p><strong>说明:</strong> 在实际开发中,如果搞不清楚运算符的优先级,可以使用括号来确保运算的执行顺序。</p>
</blockquote>

<p><strong>Friendly reminder:</strong> This series are my own study notes of <strong><a href="https://github.com/jackfrued/Python-100-Days">Python-100-Days</a></strong>. I do not own copyright of some of the content. Nor is this a good tutorial of Python. But if you find mistakes or errors in the notes, please tell me. I really appreciate that. <strong>The whole series are not allowed to be reproduced</strong>.</p>
:ET
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
I"n<h2 id="注释">注释</h2>

<p>单行注释 - 以#和空格开头的部分
多行注释 - 三个引号开头,三个引号结尾 (单引号与双引号仅有微小区别,可以忽略)</p>

<h4 id="单行注释">单行注释</h4>
<pre><code class="language-Python">a = b + c # 这是一条注释
</code></pre>
<h4 id="多行注释">多行注释</h4>
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
3
4
5
6
</pre></td><td class="rouge-code"><pre><span class="k">print</span><span class="p">(</span><span class="s">"下面是多行注释"</span><span class="p">)</span>
<span class="s">"""
print("我是注释")
print("因为是注释")
print("所以不会进行编译")
"""</span>
</pre></td></tr></tbody></table></code></pre></div></div>

<h2 id="数据类型">数据类型</h2>

<h4 id="常用数据类型">常用数据类型:</h4>

<ul>
<li>整形 int</li>
<li>浮点型 float</li>
<li>字符串型 ‘hello’ or “hello” (单引号与双引号仅有微小区别,可以忽略)</li>
<li>布尔型 True or False</li>
</ul>

<h4 id="变量">变量</h4>

<ul>
<li>变量命名:建议采用 <strong>全小写加下划线</strong> 的拼写,不能以数字开头,大小写敏感,见名识义。</li>
<li>使用<code class="highlighter-rouge">type</code>函数检查变量的类型
<pre><code class="language-Python">a = 100
b = 12.345
c = 1 + 5j
d = 'hello, world'
e = True
print(type(a)) # &lt;class 'int'&gt;
print(type(b)) # &lt;class 'float'&gt;
print(type(c)) # &lt;class 'complex'&gt;
print(type(d)) # &lt;class 'str'&gt;
print(type(e)) # &lt;class 'bool'&gt;
</code></pre>
</li>
<li>使用Python内置函数转换变量类型</li>
<li><code class="highlighter-rouge">int()</code>:将一个数值或字符串转换成整数,可以指定进制。</li>
<li><code class="highlighter-rouge">float()</code>:将一个字符串转换成浮点数。</li>
<li><code class="highlighter-rouge">str()</code>:将指定的对象转换成字符串形式,可以指定编码。</li>
<li><code class="highlighter-rouge">chr()</code>:将整数转换成该编码对应的字符串(一个字符)。</li>
<li><code class="highlighter-rouge">ord()</code>:将字符串(一个字符)转换成对应的编码(整数)。</li>
</ul>

<h4 id="运算符">运算符</h4>

<table>
<thead>
<tr>
<th>运算符</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td><code class="highlighter-rouge">[]</code> <code class="highlighter-rouge">[:]</code></td>
<td>下标,切片</td>
</tr>
<tr>
<td><code class="highlighter-rouge">**</code></td>
<td>指数</td>
</tr>
<tr>
<td><code class="highlighter-rouge">~</code> <code class="highlighter-rouge">+</code> <code class="highlighter-rouge">-</code></td>
<td>按位取反, 正负号</td>
</tr>
<tr>
<td><code class="highlighter-rouge">*</code> <code class="highlighter-rouge">/</code> <code class="highlighter-rouge">%</code> <code class="highlighter-rouge">//</code></td>
<td>乘,除,模,整除</td>
</tr>
<tr>
<td><code class="highlighter-rouge">+</code> <code class="highlighter-rouge">-</code></td>
<td>加,减</td>
</tr>
<tr>
<td><code class="highlighter-rouge">&gt;&gt;</code> <code class="highlighter-rouge">&lt;&lt;</code></td>
<td>右移,左移</td>
</tr>
<tr>
<td><code class="highlighter-rouge">&amp;</code></td>
<td>按位与</td>
</tr>
<tr>
<td><code class="highlighter-rouge">^</code> <code class="highlighter-rouge">\|</code></td>
<td>按位异或,按位或</td>
</tr>
<tr>
<td><code class="highlighter-rouge">&lt;=</code> <code class="highlighter-rouge">&lt;</code> <code class="highlighter-rouge">&gt;</code> <code class="highlighter-rouge">&gt;=</code></td>
<td>小于等于,小于,大于,大于等于</td>
</tr>
<tr>
<td><code class="highlighter-rouge">==</code> <code class="highlighter-rouge">!=</code></td>
<td>等于,不等于</td>
</tr>
<tr>
<td><code class="highlighter-rouge">is</code> <code class="highlighter-rouge">is not</code></td>
<td>身份运算符</td>
</tr>
<tr>
<td><code class="highlighter-rouge">in</code> <code class="highlighter-rouge">not in</code></td>
<td>成员运算符</td>
</tr>
<tr>
<td><code class="highlighter-rouge">not</code> <code class="highlighter-rouge">or</code> <code class="highlighter-rouge">and</code></td>
<td>逻辑运算符</td>
</tr>
<tr>
<td><code class="highlighter-rouge">=</code> <code class="highlighter-rouge">+=</code> <code class="highlighter-rouge">-=</code> <code class="highlighter-rouge">*=</code> <code class="highlighter-rouge">/=</code> <code class="highlighter-rouge">%=</code> <code class="highlighter-rouge">//=</code> <code class="highlighter-rouge">**=</code> <code class="highlighter-rouge">&amp;=</code> <code class="highlighter-rouge">|=</code> <code class="highlighter-rouge">^=</code> <code class="highlighter-rouge">&gt;&gt;=</code> <code class="highlighter-rouge">&lt;&lt;=</code></td>
<td>(复合)赋值运算符</td>
</tr>
</tbody>
</table>

<blockquote>
<p><strong>说明:</strong> 在实际开发中,如果搞不清楚运算符的优先级,可以使用括号来确保运算的执行顺序。</p>
</blockquote>

<p><strong>Friendly reminder:</strong> This series are my own study notes of <strong><a href="https://github.com/jackfrued/Python-100-Days">Python-100-Days</a></strong>. I do not own copyright of some of the content. Nor is this a good tutorial of Python. But if you find mistakes or errors in the notes, please tell me. I really appreciate that. <strong>The whole series are not allowed to be reproduced</strong>.</p>
:ET
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
I"m<p><strong>Friendly reminder:</strong> This series are my own study notes of <strong><a href="https://github.com/jackfrued/Python-100-Days">Python-100-Days</a></strong>. I do not own copyright of some of the content. Nor is this a good tutorial of Python. But if you find mistakes or errors in the notes, please tell me. I really appreciate that. <strong>The whole series are not allowed to be reproduced</strong>.</p>

<h2 id="tools-used">Tools used:</h2>

<ul>
<li>Python 3.8 Win</li>
<li>PyCharm</li>
<li><a href="https://github.com/jackfrued/Python-100-Days">Python-100-Days</a></li>
<li><a href="http://pingce.ayyz.cn:9000/vijos/Index.asp">Ayyz-Vijos</a></li>
<li><a href="https://help.github.com/cn/github/writing-on-github/basic-writing-and-formatting-syntax#ignoring-markdown-formatting">MarkDown help</a></li>
</ul>

<h2 id="catalog">Catalog:</h2>

<p>-</p>
:ET
Loading

0 comments on commit 8531ca3

Please sign in to comment.