古人學(xué)問(wèn)無(wú)遺力,少壯工夫老始成。
紙上得來(lái)終覺(jué)淺,絕知此事要躬行。
——陸游

1. 前言
在這個(gè)生活中處處都是大數(shù)據(jù)和人工智能的時(shí)代,總是能在各種角落看到 Python 的培訓(xùn)廣告。我招架不住敵方的猛烈攻勢(shì),敗下陣來(lái)。經(jīng)過(guò)了一分鐘的深思熟慮,我決定利用我的三分鐘熱情進(jìn)行回?fù)簦?strong>從零開(kāi)始自學(xué) Python。
2.
Reading and Writing Files with Python
使用 Python 讀寫(xiě)文件
2.1
Steps to reading or writing files in Python
使用 Python 讀寫(xiě)文件的步驟
Call the
open()function to return aFileobject.
調(diào)用open()函數(shù),返回一個(gè)File對(duì)象。Call the
read()orwrite()method on theFileobject.
調(diào)用File對(duì)象的read()或write()方法。Close the file by calling the
close()method on theFileobject.
讀寫(xiě)操作完成后,調(diào)用File對(duì)象的close()方法,關(guān)閉該文件。