文件操作的基本功能:
open 打開文件
rw 讀寫權限
read讀取內容、write寫入內容
close關閉文件。
代碼如下:
#!/usr/bin/python # -*- coding: utf-8 –*- file1 = open("file1.txt","r") file2 = open("file2.txt","w") s = file1.read() w = file2.write(s) file1.close() file2.close()
讀書和健身總有一個在路上