Skip to content

Commit a8d8639

Browse files
committed
20191205 Update Slides
1 parent 2ae6c2f commit a8d8639

File tree

4 files changed

+30
-8
lines changed

4 files changed

+30
-8
lines changed

index.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1695,6 +1695,22 @@ <h4>(<time datatime="2019-11-28 19:00">2019/11/28</time>)</h4>
16951695
</nav>
16961696
</details>
16971697
</section>
1698+
<section>
1699+
<details>
1700+
<summary>
1701+
<h2>Python: File I/O</h2>
1702+
<h4>(<time datetime="2019-12-05 19:00+08:00">2019/12/05</time>)</h4>
1703+
</summary>
1704+
<p class="tags">
1705+
<a href="#">Python</a>
1706+
</p>
1707+
<nav>
1708+
<ul>
1709+
<li><a href="slides/20191205-Python-File/index.html" target="_blank">課程投影片</a></li>
1710+
</ul>
1711+
</nav>
1712+
</details>
1713+
</section>
16981714
</div>
16991715
</main>
17001716
<footer>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import json
2+
3+
with open('test.txt', 'w') as File:
4+
Data = {'NAME': 'OWO', 'LIST': [1, 3, 4], 'FLOAT': 3.14}
5+
json.dump(Data, File)
6+
7+
with open('test.txt', 'r') as File:
8+
Data = json.load(File)
9+
print(type(Data), Data)
10+
print(type(Data['LIST']), Data['LIST'])
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"NAME": "OWO", "LIST": [1, 3, 4], "FLOAT": 3.14}

slides/20191205-Python-File/index.html

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ <h2>課程簡介</h2>
4949
<ul>
5050
<li>File Object</li>
5151
<li>JSON</li>
52-
<li>CSV</li>
5352
</ul>
5453
</section>
5554
</section>
@@ -157,22 +156,18 @@ <h2>使用 JSON 格式進行檔案存取</h2>
157156
158157
with open('test.txt', 'w') as File:
159158
Data = {'NAME': 'OWO', 'LIST': [1, 3, 4], 'FLOAT': 3.14}
160-
json.dump(Data, File)
159+
json.dump(Data, File) # 用JSON格式進行資料儲存
161160
162161
with open('test.txt', 'r') as File:
163-
Data = json.load(File)
162+
Data = json.load(File) # 加載一個JSON格式的資料
164163
print(type(Data), Data)
165164
print(type(Data['LIST']), Data['LIST'])
166165
```
167166
</script>
168167
</section>
169168
</section>
170-
<!-- CSV -->
171169
<section>
172-
<section>
173-
<h2>使用 CSV 格式進行檔案存取</h2>
174-
<pre><code class="python">import csv</code></pre>
175-
</section>
170+
<h2>Q & A</h2>
176171
</section>
177172
</div>
178173
</div>

0 commit comments

Comments
 (0)