2

私はこれを言うことである bencode ライブラリから bdecode を使用しようとしています:

def bdecode(x):
    try:
        r, l = decode_func[x[0]](x, 0)
    except (IndexError, KeyError, ValueError):
        raise BTFailure("not a valid bencoded string")
    if l != len(x):
        raise BTFailure("invalid bencoded value (data after valid prefix)")
    return r

from types import StringType, IntType, LongType, DictType, ListType, TupleType

init のここにあります:

ここに画像の説明を入力

しかし、私のコードでは、エラーのために結果が得られません。実際、インポートでは bdecode が見つかりませんが、その理由がわかりません。これは簡単なコードとエラー出力です:

from bencode import *

blabla = 'd8:announce70:http://tracker.t411.io:56969/c5faa6720249d33ff6ba2af48640af89/announce7:comment29:https://www.t411.io/t/524280210:created by19:https://www.t411.io13:creation datei1431685353e4:infod6:lengthi14634059e4:name22:Charlie-Hebdo-1178.pdf12:piece lengthi262144e6:pieces1120:'
myprint = bdecode(blabla)
print myprint

ここに画像の説明を入力

ベンコードのインストールについては、「pip install bencode」を作成しました

4

1 に答える 1