zoukankan      html  css  js  c++  java
  • python标准库介绍——22 UserList 模块详解

    ==UserList 模块==
    
    
    ``UserList`` 模块包含了一个可继承的列表类 (事实上是对内建列表类型的 Python 封装).
    
    在 [Example 2-16 #eg-2-16] 中, //AutoList// 实例类似一个普通的列表对象, 但它允许你通过赋值为列表添加项目.
    
    ====Example 2-16. 使用 UserList 模块====[eg-2-16]
    
    ```
    File: userlist-example-1.py
    
    import UserList
    
    class AutoList(UserList.UserList):
    
        def _ _setitem_ _(self, i, item):
            if i == len(self.data):
                self.data.append(item)
            else:
                self.data[i] = item
    
    list = AutoList()
    
    for i in range(10):
        list[i] = i
    
    print list
    
    *B*[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]*b*
    ```
  • 相关阅读:
    Nginx配置文件详解
    Mycat概述
    日志切割之Logrotate
    js数组(二)
    js数组(一)
    sass颜色
    scss
    HTML5新属性
    HTML5新元素
    Bootstrap
  • 原文地址:https://www.cnblogs.com/xuchunlin/p/7763717.html
Copyright © 2011-2022 走看看