gpt4 book ai didi

python - 将文件转换为 HEX 字符串 Python

转载 作者:IT老高 更新时间:2023-10-28 20:25:24 25 4
gpt4 key购买 nike

如何使用 Python 将文件转换为 HEX 字符串?我已经在谷歌上搜索了这个,但似乎找不到任何有用的东西。

最佳答案

import binascii
filename = 'test.dat'
with open(filename, 'rb') as f:
content = f.read()
print(binascii.hexlify(content))

关于python - 将文件转换为 HEX 字符串 Python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3964245/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com