python 创建类的几种方法

第一种:

class test(): 

    ...:     num = 0 

    ...:                                                                                                      

test1 = test()                                                                                       

test1.num                                                                                            

0

第二种:

person2 = type("person",(),{"num":0})                                                                

p2 = person2()                                                                                       

p2.num                                                                                               

0

发布了267 篇原创文章 · 获赞 36 · 访问量 19万+

猜你喜欢

转载自blog.csdn.net/qq_40270754/article/details/96118962