类中意外的缩进错误__init__

费萨尔

在运行时,我在init函数中收到一个缩进错误,我试图通过移动错误行来解决它来解决它。

class Category:
 """
 Creates category class, possible child class of products
 Parameters
­­­­­­­­­­
 name : str, default blank
 Desired name of category
 category_type : str, default blank
 type of category
 model : int , default 0 
 model of category in years
 """
#Declaring __init__()Function
def __init__(self,name="",category_type="",model=0):
        """
           Constructs all the necessary attributes for the category object.
         Parameters
         ----------
            name : str
                 name of the category
            category_type : str
                category type of the category
            model : int
                year of the category
        """
     self.name = name
     self.category_type = category_type
     self.model = model
     print (name,"Created!") # Run when init is finished.
#Declaring print_status()Function
 def print_status(self):
  print("Category :{0}\n category type :{1}\n Model :{2}".format(self.name,self.category_type,self.model))

p1 = Category("Iphone","Technology",2020)
p1.print_status()

错误消息:文件“”,第26行self.name =名称^ IndentationError:unindent与任何外部缩进级别都不匹配

费德里科·鲍(FedericoBaù)

是Docstring!

def __init__(self,name="",category_type="",model=0):
    """
        Constructs all the necessary attributes for the category object.
        Parameters
        ----------
        name : str
        name of the category
        category_type : str
        category type of the category
        model : int
        year of the category
    """
    self.name = name
    self.category_type = category_type
    self.model = model
    print (name,"Created!") # Run when init is finished.
    #Declaring print_status()Function
    def print_status(self):
    print("Category :{0}\n category type :{1}\n Model :{2}".format(self.name,self.category_type,self.model))

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

缩进错误:意外的缩进

来自分类Dev

PHP 5.6.3解析错误:语法错误,类中意外的“ [”

来自分类Dev

PHP 5.6.3解析错误:语法错误,类中意外的“ [”

来自分类Dev

为什么这是Python中意外的缩进?

来自分类Dev

意外的缩进错误脚本

来自分类Dev

意外的缩进错误脚本

来自分类Dev

类型错误:__init__() 在另一个类中启动类时获得了意外的关键字参数

来自分类Dev

语法错误,类方法中意外的 T_DOUBLE_ARROW

来自分类Dev

Django教程:意外的缩进错误

来自分类Dev

意外的缩进错误 - 为什么?

来自分类Dev

我收到“意外的缩进错误”

来自分类Dev

类型错误:__init__() 得到了一个意外的关键字参数“形状”

来自分类Dev

错误:__init__() 得到了意外的关键字参数“n_splits”

来自分类Dev

Pygame类和__init__

来自分类Dev

Python类__init__确认

来自分类Dev

python类的__init__方法

来自分类Dev

Python:类中的 __init__

来自分类Dev

抽象类错误“未从基类调用__init__方法”

来自分类Dev

意外的缩进错误,但缩进看起来正确

来自分类Dev

文件结尾出现意外缩进错误

来自分类Dev

语法错误Python:意外缩进

来自分类Dev

Python 3 中的意外缩进错误

来自分类Dev

Python 连接到 mysql 错误:意外缩进

来自分类Dev

找不到 IndentationError:意外缩进错误?

来自分类Dev

解析错误:语法错误,PHP中意外的“ [”

来自分类Dev

如何调试类中意外的空值来自何处?

来自分类Dev

在元类中使用__call__时__init__错误的回溯行为?

来自分类Dev

Shell脚本中意外令牌'then'附近的语法错误

来自分类Dev

cPanel中意外令牌'newline'附近的语法错误

Related 相关文章

热门标签

归档