[py]class的特殊方法
| 类方法 | 解释 |
|---|---|
| hasattr | hasattr(class) |
| getattr | - |
| setattr | - |
| delattr | - |
| - | - |
__getattr__ |
|
__setattr__ |
|
__delattr__ |
|
| - | - |
__getattrbute__ |
如无异常,优先. 如有连带执行__getattr__ |
| - | - |
__getitem__ |
obj[k] |
__setitem__ |
obj[k]=v |
__delitem__ |
del obj[key] |
| - | - |
__doc__ |
文档 |
__module__ |
模块 |
__class__ |
obj属于哪类 |
| - | - |
__init__ |
A() |
__call__ |
a() |
| - | - |
__str__ |
print obj |
__repr__ |
print obj |
__format__ |
- |
| - | - |
__del__ |
代码执行完后触发 |
__enter__ |
(with语句) |
__exit__ |
- |
| - | - |
__get__ |
(描述符) |
__set__ |
- |
__delete__ |
- |
| - | - |
__slots__ |
插槽 |
| - | - |
__call__ |
- |
__metaclass__ |
- |
[py]class的特殊方法的更多相关文章
- django中将views.py中的python方法传递给html模板文件
常规的模板渲染 from django.db import models # Create your models here. class ArticalType(models.Model): cap ...
- [py][mx]django get方法返回login页面
get方法返回login.html users/views.py def login(request): if request.method == "POST": pass eli ...
- associate.py 源代码 及 使用方法
ORB_SLAM2运行RGBD数据集需要使用图片序列信息 使用以下代码进行汇集: #!/usr/bin/python # Software License Agreement (BSD License ...
- [py]类的专有方法
陆陆续续总结一些用到的类的特殊方法 看源码总会看到一些奇奇怪怪的写法: 掺杂着设计模式 https://coding.net/u/RuoYun/p/Python-design-pattern/git/ ...
- python3.X 安装web.py 失败的解决方法
python2.x 安装python是非常顺利的 但是 在进行 pip3 install web.py 时提示很多错误 例如缺少模块 语法错误...... 最后试了一下web.py 的dev版本 pi ...
- 【Linux】CentOS7中yumbackend.py进程的结束方法
环境: CentOS Linux release 7.3.1611 (Core) 今天启动这个不怎么用的机器,才启动,就发现后台的yum无法进行安装,持续报这个错误 Loaded plugins: f ...
- [py]使用字典get方法做数据统计
s = "aabbccc" d = {} for i in s: if i in d: d[i] += 1 else: d[i] = 0 for i in s: d[i] = d. ...
- Py高级函数和方法
Map() Redece() Dir() __len__ ---->>> len() getattr().setattr() 以及 hasattr() 参考廖雪峰----- ...
- python 调用dll中c或c++语言的带指针方法,
在项目开发中遇到了,python需要去调用一个动态链接库dll中的c++方法.这个方法的参数为一个指针类型的参数,一个bool类型参数, 在python中并未对数字类型进行区分. int LP_Agc ...
随机推荐
- VC++:Debug出错,提示错误在findfile.cpp (Line 369)
调试程序的Debug版本,出现断言框,定位于库文件findfile.cpp 第369行: void CFileFind::AssertValid() const { // if you trip th ...
- css之导航菜单的制作
通过设置<a>的背景改变样式,通过a:hover改变交互效果,改变文字颜色color 纵向 <!DOCTYPE html> <html> <head lang ...
- How to Setup Cordova for Windows 7
Setup Cordova Text Editor / IDE You may need to prepare an IDE or Editor for working. Here for examp ...
- mybatis由浅入深day01_6SqlMapConfig.xml(6.2settings全局参数配置_6.3typeAliases(类型别名)_6.4typeHandlers(类型处理器)_6.5mappers(映射配置))
6 SqlMapConfig.xml mybatis的全局配置文件SqlMapConfig.xml,配置内容和顺序如下: properties(属性) settings(全局配置参数) typeAli ...
- 超全面的JavaWeb笔记day03<JS对象&函数>
1.js的String对象(****) 2.js的Array对象 (****) 3.js的Date对象 (****) 获取当前的月 0-11,想要得到准确的月 +1 获取星期时候,星期日是 0 4.j ...
- 华为P10闪存门
随着余承东的倡议书以及五一假期3天的时间冲刷,华为的闪存门事件,似乎被冲淡了.但相信还有很多人对华为“闪存门”的起始及发展过程不是特别了解.而华为作为2017年Q1季度手机出货量的冠军,居然在4月份出 ...
- ubuntu的安装方法
Ubuntu 是一个启动速度超快.界面友好.安全性好的开源操作系统,它由全球顶尖开源软件专家开发,适用于桌面电脑.笔记本电脑.服务器以及上网本等,并且它可以永久免费使用.如果你厌倦了Windows,如 ...
- MySql学习—— 查询性能优化 深入理解MySql如何执行查询
本篇深入了解查询优化和服务器的内部机制,了解MySql如何执行特定查询,从中也可以知道如何更改查询执行计划,当我们深入理解MySql如何真正地执行查询,明白高效和低效的真正含义,在实际应用中就能扬长避 ...
- luogu P1379 八数码难题(A*算法入门详细讲解)
代码实现细节 #include<cstdio> #include<cstring> #include<iostream> using namespace std; ...
- 主流品牌服务器(Dell、HP、IBM)远程管理卡IP配置参考
版权声明:个人网络收集整理,欢迎转载! https://blog.csdn.net/niufenger/article/details/80737878 ※Dell服务器iDRAC IP配置 ※HP服 ...