python張月辰檔案file方法methods
影片376
程式碼
f = open("ascii.txt", "r")
#註解開啟open檔案ascii.txt讀取模式r開啟之後要關閉
x = f.read()
f.close()
print("檔案長度", len(x))
print("列印內容",x)
f = open("ascii.txt", "r")
y = f.readlines() #輸出成串列list,長度是列數
print(y)
f = open("ascii.txt", "r")
#註解開啟open檔案ascii.txt讀取模式r開啟之後要關閉
x = f.read()
f.close()
print("檔案長度", len(x))
print("列印內容",x)
f = open("ascii.txt", "r")
y = f.readlines() #輸出成串列list,長度是列數
print(y)
自己動手做,就會逐漸累積自己的知識與能力。https://yuechen613.blogspot.com/2024/03/pythonfilemethods.html
回覆刪除