<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>超入門教學 &#8211; 龍冥 Blog</title>
	<atom:link href="https://dragongo.co/tag/%E8%B6%85%E5%85%A5%E9%96%80%E6%95%99%E5%AD%B8/feed/" rel="self" type="application/rss+xml" />
	<link>https://dragongo.co</link>
	<description>Code &#38; Read</description>
	<lastBuildDate>Sun, 25 Jan 2026 10:30:04 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.7</generator>

<image>
	<url>https://dragongo.co/wp-content/uploads/2021/05/cropped-cropped-LOGO-2-e1655437907165-32x32.png</url>
	<title>超入門教學 &#8211; 龍冥 Blog</title>
	<link>https://dragongo.co</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>【Python超入門教學】EP2 &#124; 資料型態：新手常見誤區</title>
		<link>https://dragongo.co/python-data-types-common-errors/</link>
		
		<dc:creator><![CDATA[龍冥]]></dc:creator>
		<pubDate>Sun, 25 Jan 2026 10:24:56 +0000</pubDate>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[程式教學]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[四則運算]]></category>
		<category><![CDATA[常見錯誤]]></category>
		<category><![CDATA[資料型態]]></category>
		<category><![CDATA[超入門教學]]></category>
		<guid isPermaLink="false">https://dragongo.co/?p=2597</guid>

					<description><![CDATA[Python 資料型態超入門：掌握 int、float、str 與 Boolean 核心觀念。解析 input() 轉型陷阱與 type() 除錯技巧，並詳列變數命名保留字規範，協助初學者避開常見語法錯誤，建立正確程式邏輯。]]></description>
										<content:encoded><![CDATA[		<div data-elementor-type="wp-post" data-elementor-id="2597" class="elementor elementor-2597">
						<section class="penci-section penci-disSticky penci-structure-10 elementor-section elementor-top-section elementor-element elementor-element-052f0ea elementor-section-boxed elementor-section-height-default elementor-section-height-default" data-id="052f0ea" data-element_type="section" data-e-type="section">
						<div class="elementor-container elementor-column-gap-default">
					<div class="penci-ercol-100 penci-ercol-order-1 penci-sticky-ct    elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-f371213" data-id="f371213" data-element_type="column" data-e-type="column">
			<div class="elementor-widget-wrap elementor-element-populated">
						<div class="elementor-element elementor-element-92edea3 elementor-widget elementor-widget-text-editor" data-id="92edea3" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<p>在程式語言中，電腦需要知道「現在處理的是什麼資料」，才能決定該做什麼動作。例如：數字可以相加 (<code>1+1=2</code>)，但文字相加是串接 (<code>"1"+"1"="11"</code>)。</p>
<h2>為什麼需要資料型態？</h2>
<p>Python 雖然不需要像 C 語言一樣在宣告變數時強制定義型態（例如 <code>int a</code>），但它在執行時仍有嚴格的型態區分。若型態不對，程式會出現非預期運作方式甚至無法執行。</p>
<h3>常見的基礎型態</h3>
<p>我整理一些對於入門新手的人來講，初學必須先知道的幾個資料型態，但電腦還有很多更進階的資料型態，也很常用到，如list、tuple等型態，但為了入門學習，在本篇文章就先不提。</p>
<ul>
<li><strong>整數 (int)</strong>：Integer。完整的數字，不帶小數點。
<ul>
<li>範例：<code>1</code>, <code>50</code>, <code>10</code>, <code>18</code></li>
</ul>
</li>
<li><strong>浮點數 (float)</strong>：Floating-point。帶有小數點的數字。
<ul>
<li>範例：<code>3.14</code>, <code>0.5</code>, <code>1.0</code> (即使是 .0 也是浮點數)</li>
</ul>
</li>
<li><strong>字串 (str)</strong>：String。文字資料，必須用引號包覆。
<ul>
<li>範例：<code>"龍龍"</code>, <code>"Hello"</code>, <code>"123"</code> (被引號包起來的數字也是字串)</li>
</ul>
</li>
<li><strong>布林值 (Boolean)：只有是和否的二種狀態，常用在判斷句 (if) 中，也可以是比較運算的結果。</strong>
<ul>
<li>範例：<code>10 &gt; 3   # True</code></li>
</ul>
</li>
<li><strong>空值 (None)：代表「沒有值」、「尚未設定」。用來表示「這裡現在沒有有效資料」</strong>
<ul>
<li>範例：<code>data = None</code></li>
</ul>
</li>
</ul>
<h2>檢查資料型態：<code>type()</code></h2>
<p>當我們不確定某個變數是什麼型態時，可以使用 <code>type()</code> 函數來檢查。這在除錯（Debug）時非常重要。例如1+1出來不是2，而是11時，就可透過 type() 函數來判斷變數 (var) 是否為字串 (str) 類型造成的錯誤。</p>
<p><!-- notionvc: 82d90d5e-6176-4d3b-b273-83131b06d5e4 --></p>								</div>
				</div>
				<div class="elementor-element elementor-element-9a5ba7b elementor-widget elementor-widget-code-block-for-elementor" data-id="9a5ba7b" data-element_type="widget" data-e-type="widget" data-widget_type="code-block-for-elementor.default">
				<div class="elementor-widget-container">
					<pre class='line-numbers theme-okaidia' data-show-toolbar='yes'><code class='language-python'>n1 = 1
f1 = 3.14
s1 = &quot;文字&quot;

print(type(n1))  # 輸出：&lt;class &#039;int&#039;&gt;
print(type(f1))  # 輸出：&lt;class &#039;float&#039;&gt;
print(type(s1))  # 輸出：&lt;class &#039;str&#039;&gt;</code></pre>				</div>
				</div>
				<div class="elementor-element elementor-element-f8ef658 elementor-widget elementor-widget-text-editor" data-id="f8ef658" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<h2>數值四則運算對資料型態的影響</h2>
<p>在 Python 中，不同的運算符號會產生不同結果的資料型態，特別是<strong>除法</strong>。</p>
<h3>四則運算的寫法</h3>
<p>在變數的四則運算中，會因應結果的不同，進而產生出不同的資料型態，在撰寫code時，要稍加注意，以避免後續設計產生非預期的結果，如不確定，可透過type() 來輔助判斷結果的資料型態。</p>
<p>請特別注意除法 (/) 與取商數 (//) 的差別，如果後續程式邏輯依賴「整數」，請務必使用 <code>//</code> 或用 <code>int()</code> 轉變成整數的資料型態。</p>
<ul>
<li><code>10 / 2</code> 結果是 <code>5.0</code> (float)</li>
<li><code>10 // 2</code> 結果是 <code>5</code> (int)</li>
</ul>								</div>
				</div>
				<div class="elementor-element elementor-element-1b62eab elementor-widget elementor-widget-code-block-for-elementor" data-id="1b62eab" data-element_type="widget" data-e-type="widget" data-widget_type="code-block-for-elementor.default">
				<div class="elementor-widget-container">
					<pre class='line-numbers theme-okaidia' data-show-toolbar='yes'><code class='language-python'>a = 1
b = 50

print(a + b)   # 加法：51
print(a - b)   # 減法：-49
print(a * b)   # 乘法：50
print(a / b)   # 除法：0.02 (注意：Python 的除法結果永遠是 float)
print(a // b)  # 商數 (整除)：0 (無條件捨去小數部分)
print(a % b)   # 餘數：1
print(a ** b)  # 次方：1 的 50 次方
</code></pre>				</div>
				</div>
				<div class="elementor-element elementor-element-3850731 elementor-widget elementor-widget-text-editor" data-id="3850731" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<h2><code>input()</code> 的型態陷阱與轉型 (Type Casting)</h2>
<p>intput() 回傳的資料型態是「<strong>字串 (str)</strong>」，這是初學者很容易踩到的「新手陷阱」。</p>
<h3>陷阱：input 永遠是字串</h3>
<p>無論使用者輸入的是文字還是數字，<code>input()</code> 函數接收進來的資料，電腦<strong>一律視為字串 (str)</strong>。</p>
<p><!-- notionvc: f26de534-e08b-4c0a-aea1-9bdf1e6c728a --></p>								</div>
				</div>
				<div class="elementor-element elementor-element-63a6be5 elementor-widget elementor-widget-code-block-for-elementor" data-id="63a6be5" data-element_type="widget" data-e-type="widget" data-widget_type="code-block-for-elementor.default">
				<div class="elementor-widget-container">
					<pre class='line-numbers theme-okaidia' data-show-toolbar='yes'><code class='language-python'># 錯誤示範
user_in = input(&quot;請輸入數字：&quot;)  # 假設使用者輸入 5
# print(user_in + 1)           # 報錯！TypeError
# 原因：字串 &quot;5&quot; 不能直接跟數字 1 相加
</code></pre>				</div>
				</div>
				<div class="elementor-element elementor-element-7b0ce6a elementor-widget-divider--view-line elementor-widget elementor-widget-divider" data-id="7b0ce6a" data-element_type="widget" data-e-type="widget" data-widget_type="divider.default">
				<div class="elementor-widget-container">
							<div class="elementor-divider">
			<span class="elementor-divider-separator">
						</span>
		</div>
						</div>
				</div>
				<div class="elementor-element elementor-element-9ec22b5 elementor-widget elementor-widget-text-editor" data-id="9ec22b5" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<h3>解法：資料型態轉換</h3>
<p>下面範例中提到 user_in 的型態是 &lt;class &#8216;str&#8217;&gt;，而 user_int 的型態是 &lt;class &#8216;int&#8217;&gt;。務必記得 input 讀進來的變數若要進行運算，必須先透過 int() 或 float()進行資料型態的轉換。</p>
<ul>
<li><strong><code>int()</code></strong>：轉為整數。</li>
<li><strong><code>float()</code></strong>：轉為浮點數。</li>
<li><strong><code>str()</code></strong>：轉為字串。</li>
</ul>								</div>
				</div>
				<div class="elementor-element elementor-element-306465c elementor-widget elementor-widget-code-block-for-elementor" data-id="306465c" data-element_type="widget" data-e-type="widget" data-widget_type="code-block-for-elementor.default">
				<div class="elementor-widget-container">
					<pre class='line-numbers theme-okaidia' data-show-toolbar='yes'><code class='language-python'># 正確寫法
user_in = input(&quot;請輸入數字：&quot;)       # 讀取輸入 (str)
user_int = int(user_in)             # 轉型為整數 (int)

print(f&quot;輸入數字+1 = {user_int + 1}&quot;) # 現在可以運算了

# 也可以寫成一行：
# age = int(input(&quot;請輸入年齡：&quot;))</code></pre>				</div>
				</div>
				<div class="elementor-element elementor-element-44e571c elementor-widget-divider--view-line elementor-widget elementor-widget-divider" data-id="44e571c" data-element_type="widget" data-e-type="widget" data-widget_type="divider.default">
				<div class="elementor-widget-container">
							<div class="elementor-divider">
			<span class="elementor-divider-separator">
						</span>
		</div>
						</div>
				</div>
				<div class="elementor-element elementor-element-0c3cc61 elementor-widget elementor-widget-text-editor" data-id="0c3cc61" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<h2>變數命名規則：保留字 (Reserved Words)</h2><p>在命名變數時，不能使用 Python 已經賦予特殊功能的單字（保留字），否則會發生語法錯誤 (<code>SyntaxError: invalid syntax</code>) 或導致程式功能異常。</p><h3>絕對不能用的字 (Keyword)</h3><p>這些字在 Python 語法中有特定用途，不能當變數名：</p><ul><li><code>if</code>, <code>else</code>, <code>for</code>, <code>while</code>, <code>class</code>, <code>def</code>, <code>return</code>, <code>import</code>, <code>True</code>, <code>False</code>, <code>None</code> 等。</li></ul><h3>建議不要用的字 (Built-in Functions)</h3><p>這些是 Python 內建的函數名，雖然語法上允許覆蓋，但會導致原本功能失效（極度危險）：</p><ul><li><code>print</code>, <code>input</code>, <code>int</code>, <code>str</code>, <code>list</code>, <code>type</code></li></ul>								</div>
				</div>
				<div class="elementor-element elementor-element-b666788 elementor-widget elementor-widget-code-block-for-elementor" data-id="b666788" data-element_type="widget" data-e-type="widget" data-widget_type="code-block-for-elementor.default">
				<div class="elementor-widget-container">
					<pre class='line-numbers theme-okaidia' data-show-toolbar='yes'><code class='language-python'># 危險示範
# print = 100
# print(&quot;Hello&quot;)  # 會報錯，因為 print 已經變成數字 100，不再是函數了</code></pre>				</div>
				</div>
					</div>
		</div>
					</div>
		</section>
				</div>
		]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>【Python超入門教學】EP1 &#124; 輸出到輸入</title>
		<link>https://dragongo.co/python-basics-input-output/</link>
		
		<dc:creator><![CDATA[龍冥]]></dc:creator>
		<pubDate>Mon, 19 Jan 2026 11:42:28 +0000</pubDate>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[程式教學]]></category>
		<category><![CDATA[input]]></category>
		<category><![CDATA[print]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[variable]]></category>
		<category><![CDATA[超入門教學]]></category>
		<guid isPermaLink="false">https://dragongo.co/?p=2569</guid>

					<description><![CDATA[輸出指令：print() 的核心與細節 prin&#8230;]]></description>
										<content:encoded><![CDATA[		<div data-elementor-type="wp-post" data-elementor-id="2569" class="elementor elementor-2569">
						<section class="penci-section penci-disSticky penci-structure-10 elementor-section elementor-top-section elementor-element elementor-element-052f0ea elementor-section-boxed elementor-section-height-default elementor-section-height-default" data-id="052f0ea" data-element_type="section" data-e-type="section">
						<div class="elementor-container elementor-column-gap-default">
					<div class="penci-ercol-100 penci-ercol-order-1 penci-sticky-ct    elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-f371213" data-id="f371213" data-element_type="column" data-e-type="column">
			<div class="elementor-widget-wrap elementor-element-populated">
						<div class="elementor-element elementor-element-92edea3 elementor-widget elementor-widget-text-editor" data-id="92edea3" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<h2><b>輸出指令：print() 的核心與細節</b></h2><p><span style="font-weight: 400;">print() 是 Python 中最基礎的指令，用於將資訊顯示在螢幕（終端機）上，最簡易的輸出純文字的方式。在有圖形化介面(UI)的軟體上，print的輸出往往會隱藏在軟體執行的後台，不會讓一般使用者看到，留給軟體工程師除錯用的。</span></p><h3><b>基本語法規則</b></h3><ul><li style="font-weight: 400;" aria-level="1"><b>全小寫</b><span style="font-weight: 400;">：Python 對大小寫敏感，必須寫成 print，寫成 Print 會報錯。</span></li><li style="font-weight: 400;" aria-level="1"><b>括號</b><span style="font-weight: 400;">：函式後方必須加上 ()。</span></li><li style="font-weight: 400;" aria-level="1"><b>內容</b><span style="font-weight: 400;">：可以是文字（需加引號）、數字、變數或運算結果。</span></li></ul>								</div>
				</div>
				<div class="elementor-element elementor-element-9a5ba7b elementor-widget elementor-widget-code-block-for-elementor" data-id="9a5ba7b" data-element_type="widget" data-e-type="widget" data-widget_type="code-block-for-elementor.default">
				<div class="elementor-widget-container">
					<pre class='line-numbers theme-okaidia' data-show-toolbar='yes'><code class='language-python'># 正確寫法
print(&quot;Hello, world!&quot;)  # 讓電腦顯示文字
print(123)              # 顯示數字

# 常見錯誤示範
# Print(&quot;Error&quot;)  &lt;-- 錯誤：指令首字不能大寫</code></pre>				</div>
				</div>
				<div class="elementor-element elementor-element-f8ef658 elementor-widget elementor-widget-text-editor" data-id="f8ef658" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<p><span style="font-size: 14pt; font-family: 'Google Sans', sans-serif; color: #1f1f1f; background-color: transparent; font-weight: bold; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-variant-position: normal; font-variant-emoji: normal; vertical-align: baseline; white-space-collapse: preserve;">控制換行與特殊符號</span></p><p dir="ltr" style="line-height: 1.3799999713897704; margin-top: 0pt; margin-bottom: 6pt;"><span style="font-size: 11pt; font-family: 'Google Sans Text', sans-serif; color: #1f1f1f; background-color: transparent; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-variant-position: normal; font-variant-emoji: normal; vertical-align: baseline; white-space-collapse: preserve;">預設情況下，Python的print() 結束後會自動換行。我們可以透過參數調整這個行為。</span></p><ul><li><span id="docs-internal-guid-1b0cc752-7fff-e7ff-051a-80064dc5bceb"><span style="font-size: 11pt; font-family: 'Google Sans Text', sans-serif; color: #1f1f1f; background-color: transparent; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-variant-position: normal; font-variant-emoji: normal; vertical-align: baseline; white-space-collapse: preserve;">取消換行 (end)：</span></span>告訴 Python 結束時不要換行，而是接上指定的字串（如空字串）。</li></ul>								</div>
				</div>
				<div class="elementor-element elementor-element-1b62eab elementor-widget elementor-widget-code-block-for-elementor" data-id="1b62eab" data-element_type="widget" data-e-type="widget" data-widget_type="code-block-for-elementor.default">
				<div class="elementor-widget-container">
					<pre class='line-numbers theme-okaidia' data-show-toolbar='yes'><code class='language-python'>print(&quot;A&quot;, end=&quot;&quot;)
print(&quot;B&quot;)
# 輸出結果為：AB</code></pre>				</div>
				</div>
				<div class="elementor-element elementor-element-3850731 elementor-widget elementor-widget-text-editor" data-id="3850731" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<ul><li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">跳脫字元 (Escape Characters)：</span><span style="font-weight: 400;"><br /></span><span style="font-weight: 400;">通常反斜線 \ 加上特定字元會有特殊功能，例如 </span><span style="font-weight: 400;">\n 代表換行(New Line)，如果要特別顯示出系統保留功能的特定文字，則需要透過跳脫字元的做法，來顯示出「\」等有特殊功能的符號本體。<br />寫法是用【\+想顯示的具有功能的保留文字】</span></li></ul>								</div>
				</div>
				<div class="elementor-element elementor-element-63a6be5 elementor-widget elementor-widget-code-block-for-elementor" data-id="63a6be5" data-element_type="widget" data-e-type="widget" data-widget_type="code-block-for-elementor.default">
				<div class="elementor-widget-container">
					<pre class='line-numbers theme-okaidia' data-show-toolbar='yes'><code class='language-python'>print(&quot;我換行了\n\n\n&quot;)  # \n 代表換行 (New Line)
print(&quot;\\&quot;)              # 顯示反斜線 \ 本身
print(&quot;\&quot;&quot;)              # 顯示雙引號 &quot; 符號</code></pre>				</div>
				</div>
				<div class="elementor-element elementor-element-7b0ce6a elementor-widget-divider--view-line elementor-widget elementor-widget-divider" data-id="7b0ce6a" data-element_type="widget" data-e-type="widget" data-widget_type="divider.default">
				<div class="elementor-widget-container">
							<div class="elementor-divider">
			<span class="elementor-divider-separator">
						</span>
		</div>
						</div>
				</div>
				<div class="elementor-element elementor-element-9ec22b5 elementor-widget elementor-widget-text-editor" data-id="9ec22b5" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<h2 dir="ltr" style="line-height: 1.3799999713897704; margin-top: 6pt; margin-bottom: 6pt;"><span style="font-size: 18pt; font-family: 'Google Sans', sans-serif; color: #1f1f1f; background-color: transparent; font-weight: bold; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-variant-position: normal; font-variant-emoji: normal; vertical-align: baseline; white-space-collapse: preserve;">變數 (Variable)：資料的「抽屜」</span></h2><h3 dir="ltr" style="line-height: 1.3799999713897704; margin-top: 0pt; margin-bottom: 6pt;"><span style="font-size: 14pt; font-family: 'Google Sans', sans-serif; color: #1f1f1f; background-color: transparent; font-weight: bold; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-variant-position: normal; font-variant-emoji: normal; vertical-align: baseline; white-space-collapse: preserve;">變數概念</span></h3><ul style="margin-top: 0; margin-bottom: 0; padding-inline-start: 48px;"><li dir="ltr" style="list-style-type: disc; font-size: 11pt; font-family: Arial, sans-serif; background-color: transparent; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-variant-position: normal; font-variant-emoji: normal; vertical-align: baseline; white-space: pre; margin-left: -12.75pt;" aria-level="1"><p dir="ltr" style="line-height: 1.3799999713897704; margin-top: 0pt; margin-bottom: 0pt;" role="presentation"><span style="font-size: 11pt; font-family: 'Google Sans Text', sans-serif; color: #1f1f1f; background-color: transparent; font-weight: bold; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-variant-position: normal; font-variant-emoji: normal; vertical-align: baseline; text-wrap-mode: wrap;">定義</span><span style="font-size: 11pt; font-family: 'Google Sans Text', sans-serif; color: #1f1f1f; background-color: transparent; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-variant-position: normal; font-variant-emoji: normal; vertical-align: baseline; text-wrap-mode: wrap;">：變數就像是一個「抽屜」，專門用來存放資料（如數字、文字）。</span></p></li><li dir="ltr" style="list-style-type: disc; font-size: 11pt; font-family: Arial, sans-serif; background-color: transparent; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-variant-position: normal; font-variant-emoji: normal; vertical-align: baseline; white-space: pre; margin-left: -12.75pt;" aria-level="1"><p dir="ltr" style="line-height: 1.3799999713897704; margin-top: 0pt; margin-bottom: 6pt;" role="presentation"><span style="font-size: 11pt; font-family: 'Google Sans Text', sans-serif; color: #1f1f1f; background-color: transparent; font-weight: bold; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-variant-position: normal; font-variant-emoji: normal; vertical-align: baseline; text-wrap-mode: wrap;">賦值 (=)</span><span style="font-size: 11pt; font-family: 'Google Sans Text', sans-serif; color: #1f1f1f; background-color: transparent; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-variant-position: normal; font-variant-emoji: normal; vertical-align: baseline; text-wrap-mode: wrap;">：在程式中，單一個等號 = 代表「賦值」，意思是</span><span style="font-size: 11pt; font-family: 'Google Sans Text', sans-serif; color: #1f1f1f; background-color: transparent; font-weight: bold; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-variant-position: normal; font-variant-emoji: normal; vertical-align: baseline; text-wrap-mode: wrap;">把右邊的資料，放進左邊的變數儲存</span><span style="font-size: 11pt; font-family: 'Google Sans Text', sans-serif; color: #1f1f1f; background-color: transparent; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-variant-position: normal; font-variant-emoji: normal; vertical-align: baseline; text-wrap-mode: wrap;">。</span></p></li></ul><h3 dir="ltr" style="line-height: 1.3799999713897704; margin-top: 6pt; margin-bottom: 6pt;"><span style="font-size: 14pt; font-family: 'Google Sans', sans-serif; color: #1f1f1f; background-color: transparent; font-weight: bold; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-variant-position: normal; font-variant-emoji: normal; vertical-align: baseline; white-space-collapse: preserve;">命名與使用</span></h3><p data-pm-slice="1 1 [&quot;blockquote&quot;,{}]">雖然後期版本的 Python 允許使用中文變數名稱（例如 <code>名字="龍龍"</code>），但在實務開發中<strong>強烈不建議</strong>這樣寫。這容易導致編碼問題造成非預期的結果或錯誤，即使可以運作，但在不同的電腦環境下，有高機率會無法執行，請養成使用英文命名變數的習慣。</p><p data-pm-slice="1 1 [&quot;blockquote&quot;,{}]">強烈建議即使是入門學習，也養成<strong>不要用 a、b、c 這類簡易的變數名稱</strong>，養成習慣後，在程式碼寫到超過一百行時，將會很難除錯，也很難與他人合作 (我看過傳承超過十年的系統原始碼都是abc，真的會逼死人&#8230;)</p>								</div>
				</div>
				<div class="elementor-element elementor-element-306465c elementor-widget elementor-widget-code-block-for-elementor" data-id="306465c" data-element_type="widget" data-e-type="widget" data-widget_type="code-block-for-elementor.default">
				<div class="elementor-widget-container">
					<pre class='line-numbers theme-okaidia' data-show-toolbar='yes'><code class='language-python'># 定義變數
name = &quot;龍龍&quot;  # 文字類（字串），前後都要加雙引號
age = 18       # 數字類（整數），不需要加引號

# 使用變數
print(name)    # 印出：龍龍
print(age)     # 印出：18
print(f&quot;你好，我是{name}，今年{age}歲&quot;)  #印出：我是龍龍，今年18歲</code></pre>				</div>
				</div>
				<div class="elementor-element elementor-element-44e571c elementor-widget-divider--view-line elementor-widget elementor-widget-divider" data-id="44e571c" data-element_type="widget" data-e-type="widget" data-widget_type="divider.default">
				<div class="elementor-widget-container">
							<div class="elementor-divider">
			<span class="elementor-divider-separator">
						</span>
		</div>
						</div>
				</div>
				<div class="elementor-element elementor-element-0c3cc61 elementor-widget elementor-widget-text-editor" data-id="0c3cc61" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<h2 data-pm-slice="1 1 []">使用者互動：<code>input()</code></h2><p data-pm-slice="1 1 []">讓程式不再只是單向輸出，而是能接收使用者的指令。</p><h3 data-pm-slice="1 1 []">基本語法</h3><ul><li><p><strong>語法</strong>：<code>input("提示文字")</code></p></li><li><p><strong>特性</strong>：<code>input</code> 接收到的資料，預設型別永遠是 <strong>字串 (String)</strong>。</p></li></ul><h3>實戰範例</h3>								</div>
				</div>
				<div class="elementor-element elementor-element-b666788 elementor-widget elementor-widget-code-block-for-elementor" data-id="b666788" data-element_type="widget" data-e-type="widget" data-widget_type="code-block-for-elementor.default">
				<div class="elementor-widget-container">
					<pre class='line-numbers theme-okaidia' data-show-toolbar='yes'><code class='language-python'># 1. 顯示提示並等待輸入，將結果存入變數 name
name = input(&quot;請輸入你的名字:&quot;)

# 2. 再次等待輸入，存入變數 age_input
age_input = input(&quot;請輸入你的年齡:&quot;)

# 3. 結合變數進行輸出
print(f&quot;你的名字是{name}&quot;)
print(f&quot;{name}是{age_input}歲，聰明的人&quot;)</code></pre>				</div>
				</div>
					</div>
		</div>
					</div>
		</section>
				</div>
		]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
