Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/344.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在python中,当我在BiteStream中读取jpeg文件时,我希望jpeg文件只有十六进制值,但我发现所有特殊字符(,!,#,$等)_Python_Encryption_Jpeg_File Handling_Data Hiding - Fatal编程技术网

在python中,当我在BiteStream中读取jpeg文件时,我希望jpeg文件只有十六进制值,但我发现所有特殊字符(,!,#,$等)

在python中,当我在BiteStream中读取jpeg文件时,我希望jpeg文件只有十六进制值,但我发现所有特殊字符(,!,#,$等),python,encryption,jpeg,file-handling,data-hiding,Python,Encryption,Jpeg,File Handling,Data Hiding,输出: 中国内地\\\\\xf\\\xf\\\xf\\\\\\\\\\x0\\\x01\\\x01\\x01\\x01\\\x01\\\\x0\\\\\x0\\\\\\\\\\\\\\x0\\\\\\\x01\x01\x01\\x01\\\\\x0 0 0 0\\\\\\x00\\x00\\\\x00\\\\\x00\\\\\\x0 0\\\\\\\\\x0 0 0 0 0\\\\\\\\\\\\\\x0 0 0 0 0 0 0\\\\\\\\\\\\\\\x0 0 0 0 0 0\\\\\\\

输出: 中国内地\\\\\xf\\\xf\\\xf\\\\\\\\\\x0\\\x01\\\x01\\x01\\x01\\\x01\\\\x0\\\\\x0\\\\\\\\\\\\\\x0\\\\\\\x01\x01\x01\\x01\\\\\x0 0 0 0\\\\\\x00\\x00\\\\x00\\\\\x00\\\\\\x0 0\\\\\\\\\x0 0 0 0 0\\\\\\\\\\\\\\x0 0 0 0 0 0 0\\\\\\\\\\\\\\\x0 0 0 0 0 0\\\\\\\\\\\\\\\\\\\\\\\\x0 0 0 0 0 0 0 0 0 r\x11\r\x0e\x0f\x10\x10\x11\x10\n\x0c\x12\x13\x12\x10\x13\x0f\x10\x10\x10\x10\xff\X0\x00\x0b\x08\x02\x00\x01\0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \X0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\x06AQ\x07\x13“aq\x142\x81\x91\xa1\xf0\x08\xb1\xc1\xd1\x15\B\xe1\xf13R\x16$Cbr\x82\xa2\x92\x17%&D\xb2\t4STcds\x83\xc2\xd2\xff\xda\x00\x08\x01\x01\x00\x00


有可能以十六进制格式获取此信息吗?您能解释一下为什么存在特殊字符吗?

特殊字符是因为你正在读取字节。如果你想要十六进制,你必须自己转换它。例如,
有一个十六进制值
21
,如果我计算正确。这回答了你的问题吗?@Peter你知道有什么函数给出正确的十六进制格式吗?为什么我想要十六进制格式,因为我想转换十六进制值转换为十进制值,在当前的格式中,我很难做到这一点。为什么不直接将字节转换为十进制呢?我想可以使用
[ord(I)for I in file.read()]
,甚至
映射(ord,file.read())
def encryption(pathname,filename):
with open(pathname+filename,"rb") as file:
    jpgdata=file.read()
print(jpgdata)