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


读书和健身总有一个在路上

猜你喜欢

转载自www.cnblogs.com/Renqy/p/12755739.html