简体   繁体   中英

What is the equivalent of BinaryWriter.Write() from C# in Python?

So I have this function in a C# program:

public void Write(BinaryWriter writer)
    {
        writer.Write(0x6369676F6C6572uL | ((ulong)Type << 56));
        writer.Write(Revision);
        writer.Write((ulong)(int)((uint)IsFavorite.ToInt() & 1u));
    }

I would like to translate it to Python but I'm not sure how, I found a package for python called binstream but I'm not sure how am I supposed to translate stuff like 0x6369676F6C6572uL to Python.

Any advice is welcome!

我遇到了同样的问题,发现这个https://pypi.org/project/binstream/它声称与 BinaryReader 和 BinaryWriter 兼容

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM