python3 一些基础操作笔记
作者:互联网
读取文件模板
1 # -*- coding: utf-8 -*- 2 import glob 3 filepath = glob.glob('**/kernel_log*', recursive=True) 4 print(filepath) 5 6 for path in filepath: 7 with open(path, mode='r', encoding='utf-8') as f: 8 print("filepath is " + path) 9 line_num = 1 10 for line in f.read().splitlines(): 11 if cam_err in line: 12 print(str(line_num)+":"+line) 13 line_num += 1 14 print("-"*10 + "end" + "-"*10)View Code
标签:filepath,glob,笔记,num,path,print,操作,line,python3 来源: https://www.cnblogs.com/waterzhm/p/16456777.html