• item系列


    # # # item 系列与[]去访问值有联系
    # # obj = {"K" : "V"}
    # # print(obj)  # 字典的对象
    # # print(obj["K"])
    # 
    # # class B:
    # #     def __getitem__(self, item):
    # #         print("执行我了")
    # #         return "BBBB"
    # #
    # #     def __setitem__(self, key, value):
    # #         print(key,value)
    # #
    # # b = B()
    # # # print(b["a"])
    # # # print(b["k"])
    # # b["k"] = "value"
    # # print(b["k"])
    # 
    # 
    # # 在内置的模块中一些特殊的方法要求必须实现 __getitem__,__setitem__  才能实现
    # # class B:
    # #     def __getitem__(self, item):
    # #         return getattr(self,item)
    # #
    # #     def __setitem__(self, key, value):
    # #         setattr(self,key,value)
    # #     def __delitem__(self, key):
    # #         # print(key)
    # #         delattr(self,key)
    # #
    # # b = B()
    # # b["k1"] = "v1"   #__setitem__
    # # print(b["k1"])    # __getitem__
    # # del b["k1"]     # __delitem__
    # # print(b["k1"])
    # 
    # class C:
    #     def __init__(self,lst):
    #         self.lst = lst
    # 
    #     def __setitem__(self, key, value):
    #         self.lst[key] = value
    #     def __getitem__(self, item):
    #         return self.lst[item]
    #     def __delitem__(self, key):
    #         self.lst.pop(key)
    # 
    # c = C([1,2,3,4,5,6])
    # print(c[0])
    # c[0] = "999"
    # print(c[0])
    # del c[0]
    # print(c.lst)
    
    
    #
    # 每一个对象都是扑克牌
    # 查看每个对象来查看整幅牌,
    # 从这一副牌中随机抽取一张牌
    # 打乱这副牌顺序的功能
  • 相关阅读:
    POWERSHELL脚本执行权限
    tcp连接状态查看
    shutdown vs close
    tcp timestamps
    与TIME_WAIT相关的几个内核参数修改测试讨论结论
    添加 vip
    tcp nonblock connection rst
    tcp keepalive选项
    grep搜索文本
    protobuf 测试使用
  • 原文地址:https://www.cnblogs.com/yfjly/p/10605819.html
Copyright © 2020-2023  润新知