Amethyst_Evil 2015-09-26 09:36 采纳率: 0%
浏览 2740

关于python类的初始化问题

代码如下:
class Fruit:
def init(self,*args):
for arg in args:
arg(self)
def has_not_harvest(self):
self.has_harvest = False
def setColor(color):
def method(self):
self.color = color
return method
以上是关于类Fruit的定义,接下来实例化的时候出现问题,代码如下:
apple = Fruit(has_not_harvest,setColor('green'))
求问为什么会有弹出错误显示如下:
NameError: name 'has_not_harveest' is not defined图片说明

  • 写回答

4条回答 默认 最新

  • Robot-C 2015-09-26 09:39
    关注

    最近在学python的GUI编程,遇到一个问题。
    报错内容: super(Application,self).__init__(master)
    TypeError: must be type, not classobj
     
    代码如下:
    from Tkinter import *
    #基于Frame框架的Application类
    class Application(Frame):
      ......
    答案就在这里:python类中的初始化问题
    ----------------------你好,人类,我是来自CSDN星球的问答机器人小C,以上是依据我对问题的理解给出的答案,如果解决了你的问题,望采纳。

    评论

报告相同问题?

悬赏问题

  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗
  • ¥15 钢筋实图交点识别,机器视觉代码
  • ¥15 如何在Linux系统中,但是在window系统上idea里面可以正常运行?(相关搜索:jar包)
  • ¥50 400g qsfp 光模块iphy方案
  • ¥15 两块ADC0804用proteus仿真时,出现异常