内置open()函数对外部文件的操作

时间:2024-12-07 21:33:38
 >>> file=open('c://333.csv','r')  一些基本打开关闭操作
>>> s=file.read()
>>> print s
,add,age,name
0,beijing,12,zhang
1,shanghai,24,li
2,tainjing,25,wang
>>> file.close()
 >>> file=open('c://333.csv','r')
>>> file2=open('c://111.csv','w') 将333内容写到111中
>>> file2.write(file.read())
>>> file2.close()
>>> file.close()
>>> file2=open('c://111.csv')
>>> file2=open('c://111.csv','r')
>>> s=file2.read()
>>> print s
,add,age,name
0,beijing,12,zhang
1,shanghai,24,li
2,tainjing,25,wang