当前位置:网站首页>__getitem__和__setitem__
__getitem__和__setitem__
2022-06-28 02:07:00 【xx_xjm】
这里__setitem__和__setattr__有点相似,一个是在“对象.属性”的时候调用,一个是在“对象[item]”的时候调用
与__setattr__一样,设置属性要么用self.__dict__,要么用object(self, key,value)
两者差别在于,一个是a.属性的时候调用,一个是a[属性]的时候调用,a是任一个类的实例

参考自:(12条消息) python中 __setitem__()和 __setattr__()的区别_MY Qi的博客-CSDN博客
边栏推荐
- Apache——阿帕奇简介
- How to write concise code? (upper)
- The horizontal scrolling recycleview displays five and a half in one screen, which is lower than the five average distributions
- What if win11 cannot use dynamic wallpaper? Solution of win11 without dynamic wallpaper
- 测试要掌握的技术有哪些?软件测试必懂的数据库设计大全篇
- PSM summary
- Embedded DSP audio development
- 您的物联网安全性是否足够强大?
- Apache, IIS6 and ii7 independent IP hosts screen and intercept spider crawling (applicable to VPS virtual machine servers)
- 如何编写简洁代码?(上)
猜你喜欢

如何编写简洁代码?(上)

暴雨去哪儿?天气预报不准谁的锅?

论文阅读:Generative Adversarial Transformers

Mixed programming of C language and assembly language in stm32

R语言惩罚逻辑回归、线性判别分析LDA、广义加性模型GAM、多元自适应回归样条MARS、KNN、二次判别分析QDA、决策树、随机森林、支持向量机SVM分类优质劣质葡萄酒十折交叉验证和ROC可视化

Online JSON to plaintext tool

Domain Name System

【iptables&icmp】iptables默认策略中关于icmp协议的说明
![[today in history] June 25: the father of notebook was born; Windows 98 release; First commercial use of generic product code](/img/ef/a26127284fe57ac049a4313d89cf97.png)
[today in history] June 25: the father of notebook was born; Windows 98 release; First commercial use of generic product code

Severe Tire Damage:世界上第一个在互联网上直播的摇滚乐队
随机推荐
基于流的深度生成模型
Arduino esp8266 web LED control
第一次使用gcc和makefile编写c程序
嵌入式软件开发中必备软件工具
【小程序】使用font-awesome字体图标的解决文案(图文)
Agileplm exception resolution session
Mysql database operation - stored procedure, view, transaction, index, database backup
2-5 basic configuration -win2003 add attack surface
PSM总结
将PCAP转换为Json文件的神器:joy(安装篇)
Summary of software testing tools in 2021 - fuzzy testing tools
Simple elk configuration to realize production level log collection and query practice
Redis搭建集群【简单】
Packet capturing and sorting out external Fiddler -- understanding the toolbar [1]
同样是MB,差距怎么这么大呢?
多快好省,低门槛AI部署工具FastDeploy测试版来了!
The first in the industry! MOS sub evaluation model for subjective video quality experience that can run on mobile devices!
2022年R1快开门式压力容器操作特种作业证考试题库及答案
分布式事务—基于消息补偿的最终一致性方案(本地消息表、消息队列)
You got 8K in the 3-year function test, but were overtaken by the new tester. In fact, you are pretending to work hard