gpt4 book ai didi

python - 如何使用 libtorrent for python 获取 info_hash

转载 作者:太空狗 更新时间:2023-10-30 02:48:37 26 4
gpt4 key购买 nike

from libtorrent as lt
info = lt.torrent_info(open('example.torrent','rb').read())
info.info_hash()

这没有得到哈希,而是我得到了对象 <libtorrent.big_number object at ...... >

我该怎么办?

最佳答案

现有的答案为您提供了您需要的一切......但这里有一些代码可以明确说明:

import libtorrent as lt
info = lt.torrent_info(open('example.torrent','rb').read())
info_hash = info.info_hash()
hexadecimal = str(info_hash)
integer = int(hexadecimal, 16)

编辑:实际上,这是错误的 - torrent_info() 应该传递 torrent 文件的长度及其内容。修订(工作)版本:

import libtorrent as lt
torrent = open('example.torrent','rb').read()
info = lt.torrent_info(torrent, len(torrent))
info_hash = info.info_hash()
hexadecimal = str(info_hash)
integer = int(hexadecimal, 16)

关于python - 如何使用 libtorrent for python 获取 info_hash,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12058802/

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