2024-09-29 21:45:01 发布
网友
我读JPEG的前几个字节
f = open(filename, 'rb') firstTwoBytes = f.read(2) if firstTwoBytes != '\xff\xd8':
哪一个是正确的?在
所以我的字符串比较失败了。如何最好地解决这个问题?在
谢谢
试试这个:
if firstTwoBytes != b'\xff\xd8':
所以,比较二进制而不是字符串:
f = open(filename, 'rb') firstTwoBytes = f.read(2) if firstTwoBytes != b'\xff\xd8':
试试这个:
所以,比较二进制而不是字符串:
相关问题 更多 >
编程相关推荐