python3 读文件读出来的都是二进制,关键是解码的时候的问题,有一个问题就是某一行无法用utf-8来解析,我想跳过该行,使用try except进行解析,条件就是是否
能decode
with open(filepath, 'rb') as network_file: for line in network_file.readlines(): try: line = line.decode('utf-8') except: continue line_columns = line.strip().split('\t') yield line_columns