TypeError: showInformation() missing 1 required positional argument: ‘self‘
下面的代码运行就会报错
class PeopleInformation:def showInformation(self):print("这里只是一个简单的打印")if __name__ == "__main__":PeopleInformation.showInformation()
报错如下
从错误上可以明显看到 缺少1个必需的位置参数:“ self” 也就是 PeopleInformation.showInformation() 这个地方错了
看了下才知道类名后面少了一个小括号
应该如下
class PeopleInformation:def showInformation(self):print("这里只是一个简单的打印")if __name__ == "__main__":PeopleInformation().showInformation()
编译器的问题写的时候没有提示带小括号,这个接口怎么样,玩笑归玩笑,写的时候注意下即可,类名().方法名()
如果忘记的话,我们可以想象java 那样用创建的类的方法比如 tt = PeopleInformation() 然后 tt.showInformation() 这样和java 的差不多了,应该好记住一些
只不过是没有new
TypeError: showInformation() missing 1 required positional argument: ‘self‘相关推荐
- 成功解决TypeError: drop() missing 1 required positional argument: 'labels'
成功解决TypeError: drop() missing 1 required positional argument: 'labels' 目录 解决问题 解决思路 解决方法 解决问题 TypeEr ...
- Django关联数据库时报错TypeError: __init__() missing 1 required positional argument: 'on_delete'...
sgrade = models.ForeignKey("Grades",) 执行python manage.py makemigrations后出现 TypeError: __in ...
- 【bug解决】TypeError: forward() missing 1 required positional argument: ‘x‘
项目场景: 进行ReLU类的实例运算时,出现了问题 问题描述 import numpy as npclass ReLU():def __init__(self):self.mask = Nonedef ...
- TypeError: __new__() missing 1 required positional argument: ‘exemplar‘
** TypeError: new() missing 1 required positional argument: 'exemplar' ** 打开jupyter lab报错: TypeError ...
- TypeError: load() missing 1 required positional argument: ‘Loader‘?
TypeError: load() missing 1 required positional argument: 'Loader'? 问题描述 跑模型使用 yam 包l出现以下错误: File &q ...
- TypeError: load() missing 1 required positional argument: ‘Loader‘解决方案
大家好,我是爱编程的喵喵.双985硕士毕业,现担任全栈工程师一职,热衷于将数据思维应用到工作与生活中.从事机器学习以及相关的前后端开发工作.曾在阿里云.科大讯飞.CCF等比赛获得多次Top名次.现 ...
- TypeError: __init__() missing 1 required positional argument: 'on_delete' 解决办法
Django 中创建Model时报以下错误: TypeError: init() missing 1 required positional argument: 'on_delete' 代码如下: f ...
- TypeError: fit() missing 1 required positional argument: 'y'
在我们调用sklearn中的算法时,如果不小心就会遇到下面这样的问题: TypeError: fit() missing 1 required positional argument: 'y' 在fi ...
- 运行代码,出现TypeError: fit() missing 1 required positional argument: 'y',对其进行修改
from sklearn.datasets import load_boston boston = load_boston() print(boston.DESCR)#导入model_selectio ...
最新文章
- C语言:随笔9--链表
- ASP.net中页面事件的先后顺序
- wcf寄宿iis7是的 500错误
- 分别用邻接矩阵和邻接表实现图的深度优先遍历和广度优先遍历_数据结构与算法:三十张图弄懂「图的两种遍历方式」...
- 向CentOS6.6服务器安装confluence5.4.4
- 头歌 1.Pandas安装与对象使用
- 计算机上那里可以看产品密钥,使用Windows Key Viewer一键轻松查看当前计算机的产品密钥...
- 使用PLSQL演示TM锁互斥现象
- iOS--相册视频MOV转MP4
- 服务器 备份 本地文件,云服务器备份本地文件
- android edittext底线,android – 更改edittext的底线颜色
- 阿里云云呼叫中心——软电话SDK前端接入
- 论文好词好句开源共享@GitHub
- Android Button英文全部大写问题
- 顾问风采 | LF AI Data 基金会完成换届,堵俊平担任董事会主席、星爵担任会员总代表...
- keepalive (1)
- Open Judge 百练 1003 宿醉(C语言)
- Express 报错:Failed to lookup view error in views directory 处理
- 小学生灯谜计算机,小学生谜语大全
- 华为云服务器(Centos7)安装与卸载mysql8