Python __call__()方法

Python 类中一个非常特殊的实例方法,即 call()。该方法的功能类似于在类中重载 () 运算符,使得类实例对象可以像调用普通函数那样,以“对象名()”的形式使用。
举个例子:

class CLanguage:# 定义__call__方法def __call__(self,name,add):print("调用__call__()方法",name,add)
clangs = CLanguage()
clangs("曹天骄","caotianjiao")

程序执行结果为:

调用__call__()方法曹天骄 caotianjiao

参考地址:http://c.biancheng.net/view/2380.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/415042.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Android 微信登录

/1、首先你得到微信.开放平台申请开发权限:https://open.weixin.qq.com/ 申请通过效果如下即可 2、其次,阅读开发文档: https://open.weixin.qq.com/cgi-bin/showdocument?actiondir_list&tresource/res_list&verify1&idopen1…

解决ubuntu16.04 qt5.9.1无法输入中文

1. 安装 fcitx-frontend-qt5 sudo apt-get install fcitx-frontend-qt5 2. 确认该路径下存在的文件 /usr/lib/x86_64-linux-gnu/qt5/plugins/platforminputcontexts/libfcitxplatforminputcontextplugin.so 3. 将libfcitxplatforminputcontextplugin.so 复制到以下两个路径下&…

工作198:无法选中的状态一定要绑定在select上面

<el-form-item prop"department_id" label"所属部门" :label-width"formLabelWidth"><select-form change"DepartmentList" v-model"form.department_id" /></el-form-item><el-form-item v-show&quo…

惊天大神坑 关于 python-socketio 与 socket.io-client 版本兼容问题

在使用fastapi进行开发中&#xff0c;使用python-socketio作为socketi库&#xff0c;前端项目使用vue开发&#xff0c;配合socket.io-client作为client端。 我的python-socketio版本号为4.6.0 前端socket.io-client我默认安装的最新的&#xff0c;此时最新的是3.0.4,但是发现…

vscode 1.9.11 和pycharm 5.0.4 输入os.getcwd()后输出不相同

各位&#xff0c;vscode的坑&#xff1b; os.getcwd()获取当前文件的位置 例如文件目录级&#xff1a; g:\test\123 vscode 输出的是父目录的位置 实际输出的结果为&#xff1a;g:\test 预期结果:g:\test\123&#xff08;这个才是正确的&#xff09; pycharm os.getcwd() 输出…

Bitmap添加文字水印

private static Bitmap AddTimeWatermark(Bitmap mBitmap) {//获取原始图片与水印图片的宽与高int mBitmapWidth mBitmap.getWidth();int mBitmapHeight mBitmap.getHeight();Bitmap mNewBitmap Bitmap.createBitmap(mBitmapWidth, mBitmapHeight, Bitmap.Config.ARGB_8888)…

工作199:获取接口token

1第一步设置token getAction("/user/info").then(res>{Vue.ls.set(Set_Token,res.data.access_token)}) 2第二步 设置token serviceXing.interceptors.request.use(function (config) {// Do something before request is sent//window.localStorage.getItem(&…

mongoose查找若存在,则什么都不做,若不存在,则插入

直接上代码&#xff1a; ModelSchema.findOneAndUpdate( {id: searchId}, { $setOnInsert: {id: searchId,foo: foo,bar: bar,} }, { upsert: true }) .catch(error > console.error(error));

Android 启动白屏,简单解决方法

1、打开styles、找到ThemeSplash&#xff0c;或者AppTheme 添加windowBackground即可/windowFullscreen是满屏属性。可去掉 也就是添加启动背景图 <style name"ThemeSplash" parent"Theme.AppCompat.Light.NoActionBar"><item name"android…

工作200:视频上传和图片编辑功能

1眼睛一定要看清 本地接口 稳得很

highcharts x轴 按照时间 datetime排序

1、我的配置文件代码&#xff1a; var chart Highcharts.chart(warningCharts, {chart: {type: line,},style: {fontSize: 12px,color: #006cee,padding: 10rpx,},title: {text: null,},subtitle: {text: null,},series: data,xAxis: {type: datetime,dateTimeLabelFormats: …

Android 起调系统功能,打开系统浏览器,拨打电话,发送短信,手机震动,跳转到设置通知开关页面

1、打开系统浏览器 try {startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/jaredrummler/MaterialSpinner"))); } catch (ActivityNotFoundException ignored) { } 2、拨打电话 Intent intent new Intent(Intent.ACTION_DIAL, Uri.pa…

B. 重载技术(overloading)

转载于:https://www.cnblogs.com/youyuanjuyou/p/8120968.html

Highchart series一次只显示一条

核心代码如下&#xff1a; plotOptions: {series: {events: {show: function () {const chart this.chartconst series chart.serieslet i series.lengthlet otherSerieswhile (i--) {otherSeries series[i];if (otherSeries ! this && otherSeries.visible) {oth…

android xml中设置水平虚线及竖直虚线

水平线背景 <?xml version"1.0" encoding"utf-8"?> <shape xmlns:android"http://schemas.android.com/apk/res/android"android:shape"line"><strokeandroid:width"1dp"android:color"color/colorA…

highcharts默认选中最后一个点数据

效果图如下&#xff1a; 核心代码如下&#xff1a; chart: {type: line,events: {load: function () {let chart thisconst points []Highcharts.each(chart.series, function (s) {if (s.visible) {points.push(s.points[s.points.length - 1])}})chart.tooltip.refresh(p…

Ajax——php基础知识(二)

header header(content-type:text/html; charset utf-8);//设置编码格式为:utf-8 header(location:http://www.baidu.com);//设置跳转到百度首页 header(refresh:3; urlhttp://www.xiaomi.com);//设置页面间隔刷新 数据类型 <?phpheader("content-type:text/html;char…

python utc 时间

python中&#xff0c;我们使用datetime处理日期、时间相关。 获取当前时间&#xff0c;主要有两个方法&#xff1a; datetime.now datetime.now()&#xff1a;读取的时间是系统的本地时间&#xff0c;也就是说&#xff0c;如果系统时区默认没有设置&#xff0c;那么读取的就是世…

[02] JSP内置对象

1、内置对象的来历JSP是由一些内置对象的&#xff0c;即不需要定义&#xff0c;也不需要我们主动创建&#xff0c;就可以直接使用的对象。当然&#xff0c;其对象名称也是固定的&#xff0c;无法修改&#xff0c;我们可以直接调用其相关方法。在 [01] JSP的基本认识 已经说过JS…