在 Python 中,如何判断文件是否为二进制(非文本) ?
我正在用 Python 搜索大量文件,并不断地在二进制文件中获得匹配。这使得输出看起来非常混乱。
我知道我可以使用 grep -I
,但是我对数据做的比 grep 允许的更多。
In the past, I would have just searched for characters greater than 0x7f
, but utf8
and the like, make that impossible on modern systems. Ideally, the solution would be fast.