def CountLines(fname): count = 0 with open(fname, 'rb') as f: for file_line in f: file_line = file_line.strip() # print(file_line) # 空行 if file_line == b'': pass # 注释 # 开头 elif file_line.startswith(b'-->'): pass # 代码 else: count += 1 print(fname + '----', count) # 单个文件行数 # print(fname,'----count:',count) return count def WriteBinary(response,path1): with open(path1,"wb") as f2: strb = response f2.write(strb)