Python,文件

时间:2018-09-21 19:40:08   收藏:0   阅读:185
__author__ = ‘12711‘
#-*- coding:utf-8 -*-
f=open("F",‘r‘)#读文件
#f=open("F",‘w‘)#写文件
f=open("F",‘r+‘)#读写
#f=open("F",‘w+‘)#写读
#f=open("F",‘rb‘)#二进制文件
#f=open("F",‘a+‘)#追加 读
#Data=f.read()
#print(f.readline())#读一行
#print(f.readline())
#for i in range(2):
# print(f.readline())
#第三行时改变输出
‘‘‘
cout=0
for i in f:
if cout==2:
print("hahah")
cout+=1
continue
print(i)
cout+=1
‘‘‘
#print(Data)
#f=open("F").read()
#print(f)
#f.write("\n我爱你\n")
#f.write("我喜欢你")
#print(f.tell())#看指针光标

f.close()#文件关闭

原文:https://www.cnblogs.com/hjdshizhidong/p/9688094.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!