<?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>variable &#8211; 龍冥 Blog</title>
	<atom:link href="https://dragongo.co/tag/variable/feed/" rel="self" type="application/rss+xml" />
	<link>https://dragongo.co</link>
	<description>Code &#38; Read</description>
	<lastBuildDate>Mon, 19 Jan 2026 11:45:11 +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>variable &#8211; 龍冥 Blog</title>
	<link>https://dragongo.co</link>
	<width>32</width>
	<height>32</height>
</image> 
	<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>
