Python  class

3.classier classes
remove the pass statement in your class definition,then go ahead and define an init__() function for your Animal class.
pass it the argument self for now.
finally,put the pass into the body vof the init() definition.since it will expect an indented block.

class Animal(object):
def init(self):
pass

init两边都是双划线,在电脑上和手机上都看不出来,在问答里面找到了这个知识点。电脑和手机上的两条下划线看起来就像一条。

2.class

create a class called Animal in the editor.for now,in the body of your class use the pass keyword.(pass doesn't do anything ,but as a placeholder in areas of your code where python expects an expression)

syntax:
class NewClass(object):

class Animal(object):
pass

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容