0,"Arraysizemustbe>0"self._size=sizepyArrayType=ctypes.py_object*sizeself._elements=pyArrayType()self.clear(None)defclear(self,va" />

亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

Python3多線程版TCP端口掃描器

系統(tǒng) 1523 0

本文實(shí)例講述了python數(shù)據(jù)結(jié)構(gòu)之Array用法,分享給大家供大家參考。具體方法如下:

            
import ctypes 
 
class Array: 
  def __init__(self, size): 
    assert size > 0, "Array size must be > 0 " 
    self._size = size 
    pyArrayType = ctypes.py_object * size 
    self._elements = pyArrayType() 
    self.clear(None) 
 
  def clear(self, value): 
     for index in range(len(self)): 
       self._elements[index] = value 
 
  def __len__(self): 
    return self._size 
 
  def __getitem__(self, index): 
    assert index >= 0 and index < len(self), "index must >=0 and <= size" 
    return self._elements[index] 
 
  def __setitem__(self, index, value): 
    assert index >= 0 and index < len(self), "index must >=0 and <= size" 
    self._elements[index] = value 
 
  def __iter__(self): 
    return _ArrayIterator(self._elements) 
 
class _ArrayIterator: 
  def __init__(self, theArray): 
    self._arrayRef = theArray 
    self._curNdr = 0 
 
  def __next__(self): 
    if self._curNdr < len(theArray): 
      entry = self._arrayRef[self._curNdr] 
      sllf._curNdr += 1 
      return entry 
    else: 
      raise StopIteration 
 
  def __iter__(self): 
    return self 


          
            
class Array2D : 
  def __init__(self, numRows, numCols): 
    self._theRows = Array(numCols) 
    for i in range(numCols): 
      self._theRows[i] = Array(numCols) 
 
  def numRows(self): 
    return len(self._theRows) 
 
  def numCols(self): 
    return len(self._theRows[0]) 
 
  def clear(self, value): 
    for row in range(self.numRows): 
      self._theRows[row].clear(value) 
 
  def __getitem__(self, ndxTuple): 
    assert len(ndxTuple) == 2, "the tuple must 2" 
    row = ndxTuple[0] 
    col = ndxTuple[1] 
    assert row>=0 and row 
            
              =0 and col
              
                = 0 and row < len(self.numRows) \ 
    and col >= 0 and col < len(self.numCols), \ 
    "row and col is invalidate" 
    theArray = self._theRows[row]; 
    theArray[col] = value 

              
            
          

希望本文所述對(duì)大家的Python程序設(shè)計(jì)有所幫助。


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號(hào)聯(lián)系: 360901061

您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺我的文章對(duì)您有幫助,請(qǐng)用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長非常感激您!手機(jī)微信長按不能支付解決辦法:請(qǐng)將微信支付二維碼保存到相冊(cè),切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對(duì)您有幫助就好】

您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺我的文章對(duì)您有幫助,請(qǐng)用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會(huì)非常 感謝您的哦!!!

發(fā)表我的評(píng)論
最新評(píng)論 總共0條評(píng)論
主站蜘蛛池模板: 九九爱精品视频 | 奇米4色| 日韩精品福利 | 日韩有码在线播放 | 国产福利一区视频 | 久久精品动漫 | 久久国产亚洲欧美日韩精品 | 国产伦一区二区三区四区久久 | 久久久久女人精品毛片 | 伊人成年综合网 | 亚洲一区二区精品推荐 | 天天干天天干天天干天天干天天干 | 在线观看国产精品入口 | 久久99亚洲精品久久 | 亚拍一区 | 亚洲自拍成人 | 亚洲一区二区三区在线视频 | 亚洲 欧美 另类中文字幕 | 日韩三级一区二区 | 国产欧美日韩中文字幕 | 伊人网伊人网 | 久久频这里精品香蕉久久 | 精品亚洲永久免费精品 | 99视频全部看免费观 | 久久伊人成人网 | 亚洲精品国产美女在线观看 | 天天射天天干天天舔 | 久久精品视频日本 | 亚洲欧美日韩综合在线 | 欧美洲精品亚洲精品中文字幕 | 青青青国产免费线在 | 日韩欧美国产一区二区三区 | 亚洲成人免费在线观看 | 国产日韩美国成人 | 黄色一及毛片 | 九九精品视频在线播放 | 爆操极品美女 | 亚洲精品色综合久久 | 九九热九九 | 亚洲免费高清视频 | 成年黄网站免费大全毛片 |