2017-04-13 9 views
0

Ich programmiere einen Steam Bot. Eine Bibliothek wurde in Python 3.5 geschrieben, aber ich brauche sie in Python 2.7, also schreibe ich sie neu. Aber ich weiß nicht, wie ich diese Funktion umschreiben soll. Kann mir jemand bitte helfen?Python 3.5 to_bytes in Python 2.7

def steam_id_to_account_id(steam_id): 
    return unicode(struct.unpack(u'>L', int(steam_id).to_bytes(8, byteorder=u'big')[4:])[0]) 

STEAM_ID wird eine ganze Zahl wie 76561198081423873 sein, und es sollte für 76561198081423873 im Fall zurückkehren account_id wäre es 121158145

Kennt jemand, wie man damit umgehen? Wow

+0

Mögliche Duplikat [Hat Python 3 \ _bytes gewesen zurück Port 2.7 Python?] (Http://stackoverflow.com/questions/16022556/has-python-3-zu-bytes-zurück-portiert-zu-python-2-7) – MooingRawr

+0

warum brauchst du es in python 2.7? Wäre es nicht einfacher, sich (selbst) nach Python 3.5 zu bewegen? –

+0

Nun, eine andere (kompliziertere) Bibliothek ist für Python 2.7 –

Antwort

1

, dh einige ERSTAUNLICH overcomplicated Code ...

def steam_id_to_account_id(steam_id): 
    return steam_id & 0xFFFFFFFF 
Verwandte Themen