list_strip = [i.strip() for i in str_result]
list_result = []
for i in list_strip:
# 判断是否为十六进制,且非空
if (is_hex(i.decode())) and (len(i) > 0):
list_result.append(i)
list_result
改进
list_filter = [i.strip() for i in str_result if i.strip() and is_hex(i.strip().decode())]
list_filter # 如此,不需条件len(i) > 0,因列表生成式会忽略空bytes数值
标签:hex,bytes,生成式,list,列表,decode,result,strip
From: https://blog.51cto.com/u_16055028/7076097