python小功能(復制文件內容到另一個文件)


文件操作的基本功能:

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()


讀書和健身總有一個在路上


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM