(Python Primary) - 廖雪峯Python3 - 11.IO編程

11.IO編程 本章IO編程都是同步IOnode 11.1文件讀寫 11.1.1讀文件 >>> f = open('/Users/michael/test.txt', 'r') # r表示讀,若不存在則拋出IOError 若是打開成功,則能夠調用read()函數一次性讀取所有文件內容,用一個str對象表示 >>> f.read() 最後調用close() >>> f.close() 結合try..
相關文章
相關標籤/搜索