将字符串作为字节转换为字符串

2024-09-29 21:45:01 发布

您现在位置:Python中文网/ 问答频道 /正文

我读JPEG的前几个字节

f = open(filename, 'rb')
firstTwoBytes = f.read(2)
if firstTwoBytes != '\xff\xd8':

哪一个是正确的?在

所以我的字符串比较失败了。如何最好地解决这个问题?在

谢谢


Tags: 字符串readif字节openfilenamejpegxff

热门问题