c# - C# 中是否有 Python 的 binascii.b2a_hex 的等效函数?
问题描述
我正在尝试从使用binascii.b2a_hex
. 我不知道任何 C# 等价物。C# 中的什么函数会给我相同的结果?
我在网上查了一下,有没有人有同样的问题,但还没有找到人。我什至寻找第三方库。我确实让我的应用程序从 Python 脚本中获取结果,但我想真实地移植代码。
def send_withlen(self, data, log = True) :
lengthstr = struct.pack(">L", len(data))
if log :
logging.debug(str(self.address) + ": Sent data with length - " + binascii.b2a_hex(lengthstr) + " " + binascii.b2a_hex(data))
totaldata = lengthstr + data
totalsent = 0
while totalsent < len(totaldata) :
sent = self.send(totaldata, False)
if sent == 0:
raise RuntimeError, "socket connection broken"
totalsent = totalsent + sent
以下是一些记录器调试行的示例,显示了函数输出的格式:
2019-10-15 00:03:14,220 root DEBUG ('192.168.0.17', 59176): Sent data with length - 0000010a 01500a010000000000000400040000000c0000001200000004000400000005000000120000000400040000000000000003000000040004000000060000000e00000004000400000004000000110000000400040000000a000000110000000400040000000b000000626172000400040000000f0000000e0100000400040000000200000057000000040004000000030000000000000004000400000009000000666f6f0004000400000007000000626f6f000400040000000d000000666f6f0004000400000008000000fb0000000400240000000e000000015024000000000000000300040000006361631a00000003000400000063617308000000040004000000010000000e000000
2019-10-15 00:03:14,292 dirsrv INFO ('192.168.0.17', 59178): Sending out list of content list servers
2019-10-15 00:03:14,293 root DEBUG ('192.168.0.17', 59178): Sent data with length - 00000008 0001c0a800119d69
解决方案
推荐阅读
- mysql - 显示特定城市本月尚未创建项目的用户
- regex - How to put a space between hyphen and next character unless it's a multi-word?
- r - 查找方程以拟合非线性非参数模型
- javascript - IE 11 不支持方法“来自”
- git - 我可以在 Azure DevOps 上更改 Git 全局配置吗
- angular7 - 无法导入 `.scss` 文件出现错误
- css - 悬停时从外部源更改 svg 的颜色
- visual-c++ - Windows X64 位系统上的 VC++ X64 位应用程序不会连续调用键盘挂钩回调过程
- ios - 如何使用 swift 4 在 pubnub 中显示在线离线用户状态?
- python - 如何通过 python 多处理填充数组?