惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

U
Unit 42
Help Net Security
Help Net Security
The Hacker News
The Hacker News
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
G
GRAHAM CLULEY
Simon Willison's Weblog
Simon Willison's Weblog
V
Vulnerabilities – Threatpost
A
Arctic Wolf
T
Tor Project blog
Jina AI
Jina AI
C
CXSECURITY Database RSS Feed - CXSecurity.com
C
Cyber Attacks, Cyber Crime and Cyber Security
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Spread Privacy
Spread Privacy
Security Latest
Security Latest
Latest news
Latest news
Last Week in AI
Last Week in AI
博客园 - 司徒正美
P
Privacy International News Feed
T
Tenable Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
腾讯CDC
博客园 - 聂微东
Scott Helme
Scott Helme
爱范儿
爱范儿
P
Proofpoint News Feed
C
CERT Recently Published Vulnerability Notes
I
Intezer
博客园 - Franky
酷 壳 – CoolShell
酷 壳 – CoolShell
L
LINUX DO - 热门话题
有赞技术团队
有赞技术团队
S
Secure Thoughts
WordPress大学
WordPress大学
The Cloudflare Blog
AWS News Blog
AWS News Blog
B
Blog RSS Feed
Cyberwarzone
Cyberwarzone
S
Security Affairs
Recent Commits to openclaw:main
Recent Commits to openclaw:main
The Register - Security
The Register - Security
L
LINUX DO - 最新话题
博客园_首页
C
Cybersecurity and Infrastructure Security Agency CISA
博客园 - 【当耐特】
T
Troy Hunt's Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
S
Securelist
S
Schneier on Security
Application and Cybersecurity Blog
Application and Cybersecurity Blog

博客园 - 菲一打

【转】Linux从入门到精通——运维工程师成长路线图——CTO马哥Linux视频教学 【转】 要做linux运维工程师的朋友,必须要掌握以下几个工具才行 【转】Linux shell笔记 【转】Linux上vi(vim)编辑器使用教程 无法远程连接SQLSERVER2000的解决方法 让Python支持中文注释 【转】python入门指引 【转】布同:如何循序渐进学习Python语言 在nagios中监控windows主机系统地址的状态 nagios中监测dns 227.7.128.68的网络状态 【转】新手该如何学python怎么学好python? 在nagios中使用python脚本监控linux主机 【转】手游公司运维之从一个人运维到运维主管 【转】VMware 克隆 Linux 系统后找不到 eth0 网卡问题 【转】sed & awk常用正则表达式 【转】Linux 服务器安全配置 【转】shell脚本实现多台服务器自动巡检--可参考学习 【转】nagios 命令解释 在nagios中使用nrpe自定义脚本
Python类的__getitem__和__setitem__特殊方法
菲一打 · 2014-05-01 · via 博客园 - 菲一打

class testsetandget:
    kk = {};  
    def __getitem__(self, key):  
        return self.kk[key];  
    def __setitem__(self, key, value):  
        self.kk[key] = value;

a = testsetandget()
a['first'] = 1
print a['first']

a.__setitem__('second', 2)
print a.__getitem__('second')
print a['second']

输出:

1

2

2

发表于 2014-05-01 12:26  菲一打  阅读(7727)  评论(0)    收藏  举报