自定义类,保存成Athlete.py文件
class Athlete:
def __init__(self, a_name, a_dob=None, a_times=[]):
self.name = a_name
self.dob = a_dob
self.times = a_times
在IDLE中调用
>>> import Athlete
>>> sarah = Athlete('Sarah Sweeney', '2002-6-17', ['1.58','2.02','2:56'])
报如下错误:
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
sarah = Athlete('Sarah Sweeney', '2002-6-17', ['1.58','2.02','2:56'])
TypeError: 'module' object is not callable
原因,没有导入类的路径
import Athlete
sarah = Athlete.Athlete('Sarah Sweeney', '2002-6-17', ['1.58','2.02','2:56'])
或者
from Athlete import Athlete
sarah = Athlete('Sarah Sweeney', '2002-6-17', ['1.58','2.02','2:56'])
相关推荐
主要介绍了Django 错误:TypeError at / 'bool' object is not callable解决,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
主要介绍了Python 出现错误TypeError: ‘NoneType’ object is not iterable解决办法的相关资料,需要的朋友可以参考下
资源(241条消息)Python中报错“TypeError:‘list‘objectisnotcallable”的解决方法知识分享
TypeError: notify.sendNotifybyWxPucher is not a function!
生成位图字体的中英文字符
TypeError: 'list' object is not callable 刚开始学习python的时候,可能会由于命名的不注意,导致也方法一直用不了,原因是在声明变量对的时候和python内置方法冲突了,导致方法被重新定义了,这样一来,方法自然...
主要介绍了Vue 报错TypeError: this.$set is not a function 的解决方法,分享给大家,需要的朋友们下面随着小编来一起学习学习吧
TypeError: loop of ufunc does not support argument 0 of type Tensor which has no callable arctan method 报错行 self.u = np.round(np.dot(self.F, self.u)) #或者 self.u = np.round(self.u + np.dot(K, ...
问题描述 因为numpy的int类型无法被json化,所以需要将numpy的int转为原生类型。 解决方案 # pandas返回的 sex_cnt = marks['sex'].value_counts() type(sex_cnt['男']) # numpy.int64 # 3种转化方法 ...
1.需要node环境支持 2.下载模拟器->微信->搜索你要扒取的小程序(点开即可) 3.打开RE文件管理器,获取root权限,从根目录开始。... 4.执行反编译命令,node wuWxapkg.js filepath 百度也有很多教程,基本大致相同,...
TypeError at / 'bool' object is not callable 编写函数如下: def index(request, pid=None, del_pass=None): if request.user.is_authenticated(): username = request.user.username useremail = request....
翻译过来是类型为“type”的TypeError对象没有len(),我报错的代码是: #coding=utf-8 print(请输入一个字符串:) a = input('') #回文的长度至少为2 if len(str) < 2: print('请不要输入空字符串!') a = ...
主要介绍了解决Python中报错TypeError: must be str, not bytes问题,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
本文研究的主要是Python使用pickle模块存储数据报错解决方法,以代码的形式展示,具体如下。 首先来了解下pickle模块 pickle提供了一个简单的持久化功能。...TypeError: write() argument must be str, not byte
为大家分享了一个解决jquery插件:TypeError:$.browser is undefined报错的方法,解决报错问题的方法也很简单,需要解决此类问题的朋友不要错过这篇文章。
Uncaught TypeError: Cannot assign to read only property 'exports' of object '#<Object>' 点开错误的文件,标注错误的地方是这样的一段代码: import {normalTime} from './timeFormat'; module....
主要介绍了JQuery报错"Uncaught TypeError: Illegal invocation"的处理方法,需要的朋友可以参考下