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

欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

Python3多線程版TCP端口掃描器

系統 1608 0

本文實例講述了python數據結構之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 

              
            
          

希望本文所述對大家的Python程序設計有所幫助。


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

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

【本文對您有幫助就好】

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

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 久久久一区二区三区视频 | 99精品视频在线观看免费专区 | 丁香婷婷综合五月六月 | naruto henta| 久草在 | 国产精品蜜臂在线观看 | 国产福利在线观看精品 | 哪里看毛片 | 亚洲综合久久成人A片红豆 日本亚洲成人 | 精品中文字幕在线观看 | 午夜18禁A片兔费看 四虎影视在线看免费完整版 | 久久精品亚洲 | 国产成人啪精品视频免费网站软件 | 久久色伦理资源站 | 亚洲免费在线播放 | 艹逼视频网 | 我爱我色成人网 | 在线观看国产 | 国产婷婷精品av在线 | 欧美日韩国产在线 | 天堂中文资源在线观看 | 草草线在成年免费视频网站 | 天天看天天干 | 日韩在线中文字幕 | 精久视频 | 99久久精品免费看国产 | 国产视频一区二区 | 日韩小视频 | 色网在线观看 | 国产小视频在线高清播放 | 一级片在线观看 | 日韩欧美国产精品第一页不卡 | 天天色天天碰 | 久久99热这里只频精品6中文字幕 | 色网站免费视频 | 天天干com | 久草在线在线精品观看 | 亚洲国产综合久久精品 | 91久久国产 | 精品无人乱码一区二区三区 | 看片地址|