使用System.Collections.Generic.List ' 1[系统.Byte]在Python中

本文关键字:Byte 系统 Python Collections System Generic List 使用 | 更新日期: 2023-09-27 17:52:52

我有一个从。net应用程序接收数据的Python脚本。如何使用类型为"System. collections . generic . list"的传入缓冲区1[System. collections . generic . list]在我的剧本里?

脚本的功能是查找和替换字符串标记,将缓冲区重新组装回System. collections . generic . list ' 1[System. collections . generic . list ' 1]。然后将缓冲区返回给。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) 

任何帮助都会很感激。谢谢!

使用System.Collections.Generic.List ' 1[系统.Byte]在Python中

问题是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]