【问题标题】:Python 3.5 to_bytes in Python 2.7Python 2.7 中的 Python 3.5 to_bytes
【发布时间】:2017-04-13 16:01:07
【问题描述】:

我正在编写一个蒸汽机器人。一个库是用 Python 3.5 编写的,但我在 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 将是一个整数,例如 76561198081423873 它应该返回 account_id 以防 76561198081423873 为 121158145

有人知道怎么处理吗?

【问题讨论】:

标签: python steam steambot


【解决方案1】:

哇,那是一些非常复杂的代码......

def steam_id_to_account_id(steam_id):
    return steam_id & 0xFFFFFFFF

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-01-24
    • 2016-02-18
    • 2017-06-28
    • 2019-09-13
    • 2018-12-24
    • 2017-07-08
    • 1970-01-01
    • 2016-08-19
    相关资源
    最近更新 更多