Python 文件读取

#coding=utf-8

import codecs  #编码包(中文)

file=codecs.open('E:\\BaiduNetdiskDownload\\基础\\day6\\aaaa.txt','r','gbk','ignore')  #文件路径,只读,中文编码,忽略打开错误提示
while True:
    linestr=file.readline()
    if linestr!='':
    	if linestr.find('吴东')!=-1:
            print(linestr)
    else :
        print('跳出循环')
        break
 		

你可能感兴趣的:(Python,python)