当前位置:网站首页>__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博客
边栏推荐
- Arduino esp8266 web LED control
- Brief history and future trend of codeless software
- 为什么大厂压力大,竞争大,还有这么多人热衷于大厂呢?
- 拾光者,云南白药!
- Is your IOT security strong enough?
- [issue 21] face to face experience of golang engineer recruited by Zhihu Society
- 第一次使用gcc和makefile编写c程序
- ARM Development Studio build编译报错
- [today in history] June 25: the father of notebook was born; Windows 98 release; First commercial use of generic product code
- 被校园暴力,性格内向的马斯克凄惨而励志的童年
猜你喜欢
随机推荐
业内首个!可运行在移动设备端的视频画质主观体验MOS分评估模型!
Basic flask: template rendering + template filtering + control statement
暴雨去哪儿?天气预报不准谁的锅?
QEMU monitor usage
为什么大厂压力大,竞争大,还有这么多人热衷于大厂呢?
Get 5 offers after being notified of layoffs
嵌入式DSP音频开发
如何编写简洁代码?(上)
CMU puts forward a new NLP paradigm - reconstructing pre training, and achieving 134 high scores in college entrance examination English
[today in history] June 20: the father of MP3 was born; Fujitsu was established; Google acquires dropcam
Is it safe to buy stocks and open an account through the account opening link of the broker manager? Want to open an account for stock trading
How to judge that the thread pool has completed all tasks?
Heartless sword Chinese English bilingual poem 004 Sword
Apache - Introduction à Apache
一位博士在华为的22年(干货满满)
RichView TRVStyle TextStyles
Brief history and future trend of codeless software
Summary of software testing tools in 2021 - fuzzy testing tools
js清空对象和对象的值:
数字化时代,企业须做好用户信息安全
![[plug in -statistical] statistics the number of code lines and related data](/img/84/ad5e78f7e0ed86d9c21cabe97b9c8e.png)








