最后发现问题是: def __init__定义时出问题了,推荐IDEA 或 pyCharm 自动提示输入,避免不必要的错误
正常__init__ 前后是双下划线,等于你没有定义init初始化函数,所以报“不需要参数”错误。
TypeError: rfind() takes no keyword arguments Process finished with exit code1 意思是rfind()方法不接受关键字参数,而代码中又使用了关键字参数 修改为位置参数后正常运行 str1 ='sunlightn'f= str1.rfind("n", 1, 2)print(f)"D:\Program Files\Python\Python37-32\python.exe"D:/demo/str_1.py-...
方法名拼写错误 导致“AttributeError: 'str' object has no attribute 'lowerr'” 该错误发生在如下代码中: 代码语言:javascript 代码运行次数:0 运行 AI代码解释 spam='THIS IS IN LOWERCASE.'spam=spam.lowerr() 10、 引用超过list最大索引 导致“IndexError: list index out of range” 该错误发生在如下...
8)变量或者函数名拼写错误(导致“NameError: name ‘fooba’ is not defined”) 该错误发生在如下代码中: 9)方法名拼写错误(导致 “AttributeError: ‘str’ object has no attribute ‘lowerr‘”) 该错误发生在如下代码中: 10)引用超过list最大索引(导致“IndexError: list index out of range”) ...
Python:TypeError: count() takes no arguments求大神帮忙看看是什么问题 calculator.py#计算器类classcount:def_init_(self,a,b):self.a=int(a)self.b=int(b)#计算加法defadd(self):returnself.a+self.btest.py#测试两个整数相加fromcalculatorimportcountc... calculato
Python写类的时候报错 TypeError: Restaurant() takes no arguments 哪位前辈帮忙看下代码哪错了,感谢 classRestaurant:def_init_(self,restaurant_name,cuisine_type):***.name=restaurant_nameself.type=cuisine_typedefdes_restaurant(self):print(***.name)print(self.
8) 变量或者函数名拼写错误(导致“ NameError: name ‘fooba’ is not defined”) 该错误发生在如下代码中: foobar = 'Al' print('My name is ' + fooba) 或者: spam = ruond(4.2) 或者: spam = Round(4.2) 9) 方法名拼写错误(导致 “ AttributeError:‘str’ object has no attribute ‘lowerr‘...
导致“NameError: name 'fooba' is not defined” 该错误发生在如下代码中: foobar = 'Al' print('My name is ' + fooba) spam = ruond(4.2) spam = Round(4.2) 9、方法名拼写错误 导致“AttributeError: 'str' object has no attribute 'lowerr'” ...
导致“AttributeError: ‘str’ object has no attribute ‘lowerr’” 该错误发生在如下代码中: spam = ‘THIS IS IN LOWERCASE.’ spam = spam.lowerr() 10、 引用超过 list 最大索引 导致“IndexError: list index out of range” 该错误发生在如下代码中: spam = [‘cat’, ‘dog’, ‘mouse’] ...