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條評論
主站蜘蛛池模板: 日产国产欧美视频一区精品 | 四色成人av永久网址 | 一级毛片免费 | 精品国产三级在线观看 | 亚洲欧美日韩中文综合在线不卡 | 亚洲国产精品久久久久网站 | 成人国产精品免费观看视频 | 午夜看片在线观看 | 久草在线播放 | 中文字幕亚洲精品 | 午夜国产在线视频 | 国产欧美精品亚洲桃花岛 | 日本成人一二三区 | 免费观看一级欧美在线视频 | 色婷婷综合久久久中文字幕 | 免费一级毛片在线播放视频 | 久久精品中文 | 亚洲精选一区 | 一区二区三区四区在线播放 | 国产精品单位女同事在线 | 亚洲日本香蕉 | 国产精品毛片一区二区在线看 | 久久人人做 | 亚洲一区二区三区首页 | 国产专区精品 | 人人人人干 | 久久久人成影片免费观看 | 欧美综合区 | 免费黄网站在线播放 | 亚洲午夜在线 | 国产精品毛片无码 | 久久久婷 | 日韩一区不卡 | 99精品丰满人妻无码A片 | 久久精品一区二区三区四区 | 九九久久99综合一区二区 | 日韩亚洲一区中文字幕在线 | 亚洲国产香蕉视频欧美 | 欧美在线一二三区 | 天天爱天天做天天干 | 深夜做爰性大片中文 |