文件操作的基本功能:
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()
读书和健身总有一个在路上
文件操作的基本功能:
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删除。