1.
在 Python 中開啟檔案時最常用的模式是什麼?
3.
告訴 Python 開始新的一行命令(command )是什麼?
5.
如果我們開啟如下面這樣的一個文件,試問我們將使用什麼語句來一次讀取文件中的一行?
myfile = open('simplelearn.txt')
6.
文字檔案中換行字元(newline character)的用途是什麼?
7.
下面 Python 程式碼的目的是什麼?
fhand = open('simplelearn.txt')
x = 0
for line in fhand:
x = x + 1
print(x)
8.
當使用者輸入不存在的檔案時,下面程式碼序列將會失敗並進行回溯。要如何避免回溯,並且使其在輸入錯誤檔名時可以列印出錯誤訊息?
fname = input('Enter the file name: ')
fhand = open(fname)
9.
下面的 Python 程式碼做了些什麼?
fhand = open('simplelearn.txt')<br> inp = fhand.read()
10.
如果您想提示使用者輸入要開啟的檔名,您會使用 Python 什麼函數?