2021-08-26 Python之类中的方法

#方法--写在类里面的函数

#类中的方法:动作
#种类:普通方法 类方法 静态方法 魔术方法

'''
普通方法格式:
def 方法名(self[参数,参数]):
pass
'''

 1 class Phone:
 2     bread='xiaomi'
 3     price=1999
 4     type='mate 30'
 5     
 6     #Phone类里面的方法:call
 7     def call(self):
 8         print('self --->',self)
 9         print('正在打电话')
10     
11 pi=Phone()
12 print(pi.bread)
13 print(pi.price)
14 
15 pi.call()

 

posted @ 2021-08-26 14:04  admin-xiaoli  阅读(33)  评论(0编辑  收藏  举报