#coding=utf-8
'''
Created on 2018年9月8日
@author: Administrator
文件读写操作
'''
#写文件
fr=open(r"E:\abc.txt",'w')
fr.write("author is wangpeng!!!!!!!\n")
fr.write("author is zhangsan!!!!!!!\n")
fr.write("author is lisi!!!!!!!\n")
fr.close()
#读文件
fw=open(r"E:\abc.txt","r")
p1=fw.read(5)#读5个字节
p2=fw.readline()#读取一行
p3=fw.readlines()#读取所有行记录
print(p1)
print(p2)
print(p3)
fw.close()
#读文件加上循环操作
fc=open(r"E:\abc.txt",'r')
cNames=fc.readlines()
for i in range(0,len(cNames)):
print i+1
print cNames[i]
fc.close()
#文件写操作
fd=open(r"E:\d.txt","w")
fd.writelines(cNames)
fd.close()