码迷,mamicode.com
首页 > 编程语言 > 详细

Python,文件

时间:2018-09-21 19:46:47      阅读:157      评论:0      收藏:0      [点我收藏+]

标签:lin   pen   16px   auth   tin   size   ==   open   utf-8   

__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()#文件关闭

Python,文件

标签:lin   pen   16px   auth   tin   size   ==   open   utf-8   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!