我有一个 Python 脚本,它从 .NET 应用程序接收数据。如何在我的脚本中使用“System.Collections.Generic.List`1[System.Byte]”类型的传入缓冲区?
脚本的功能是查找和替换字符串标记,将缓冲区重新组装回 System.Collections.Generic.List`1[System.Byte],然后将缓冲区返回给 .NET 服务器。
我非常是 Python 的新手。这是我目前所拥有的:
import array
import clr
from System.Collections.Generic import *
def SetRecvBuffer(buffer):
li = List[byte](buffer)
hookme.Debug(li)
for x in li:
hookme.Debug(x)
如有任何帮助,我们将不胜感激。谢谢!
最佳答案
问题是 Python 端的 C# List
初始化忽略了括号中给出的项目,这看起来像一个错误,现在改为使用 List.Add()
:
import clr
clr.AddReference("System.Collections")
from System.Collections.Generic import List
from System import Int32
li = List[Int32](range(3))
list(li) #returns []
li.Add(5)
list(li) #returns [5]
关于c# - 在 Python 中使用 System.Collections.Generic.List`1[System.Byte],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30586954/