您好,登录后才能下订单哦!
import sys
'''
#low 方法 适合读小文件
for index,line in enumerate(data.readlines()):#取出下标和对应的值
if index==9:
print("----ooo----")
continue
print(line.strip())
#high bige 度一行覆盖一行,常用牛逼方法
count=0
for loo in data:
if count==4:
print('-----You will die-----')
count+=1
continue
print(loo)
count+=1
'''
#光标使用
#f=open("yesok2",'r+',encoding="utf-8")#文件句柄 读写,在最后追加
#f=open("gc.txt",'w+',encoding="utf-8")#文件句柄 写读,覆盖原文件(创建新文件)后写。只会在最后追加。文件观后再打开写入会覆盖
#f=open("yesok2",'a+',encoding="utf-8")#文件句柄 追加读写
#f.close()
#f1.close()
#find_str=sys.argv[1]
#replace_str=sys.argv[2]
#for line in f:
#if find_str in line:
#line=line.replace(find_str,replace_str)
#f1.write(line)
#f.close()
#f1.close()
with open("gege",'r',encoding="utf-8") as f:
for line in f:
print(line) #执行完自动关闭文件
with open("gege",'r',encoding="utf-8") as f,open("gege",'r',encoding="utf-8") as f:
pass
with open("gege",'r',encoding="utf-8") as f,\
open("gege",'r',encoding="utf-8") as f2:
for line in f:
print(line) #执行完自动关闭文件
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。