Created
January 16, 2020 12:48
-
-
Save e96031413/d8d000ce4edbf677aef4d427ba0b281e to your computer and use it in GitHub Desktop.
使用Python進行檔案讀取及寫入
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with open ('fileName') as f: #開啟檔案,並且在操作結束後自動關閉 | |
f.write() #寫入字串 | |
f.writelines() #寫入list | |
f.read() #讀入檔案 | |
f.readline() #逐行讀取(只讀第一行,第二行要再執行一次) | |
f.readlines() #讀取全部而逐行處理(一次讀完) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment