Skip to content

Instantly share code, notes, and snippets.

@e96031413
Created January 16, 2020 12:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save e96031413/d8d000ce4edbf677aef4d427ba0b281e to your computer and use it in GitHub Desktop.
Save e96031413/d8d000ce4edbf677aef4d427ba0b281e to your computer and use it in GitHub Desktop.
使用Python進行檔案讀取及寫入
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