7——18 day 24 35min 类属性

本文通过定义一个名为'中国人'的类,详细解释了Python中类的实例化过程,包括数据属性与函数属性的使用,并展示了如何调用类的方法。
# class Chinese:
# '这是一个中国人的类'
# pass
#
# print(Chinese)
#
# #实例化到底干了什么?
# p1=Chinese() #实例化
# print(p1)


'''
1.数据属性
2.函数属性
'''

class Chinese:
'这是一个中国人的类'
dang='党'
def sui_di_tu_tan():
print('朝着墙上就是一口痰')
def cha_dui(self):
print('插到了前面')

print(Chinese.dang)
Chinese.sui_di_tu_tan()
Chinese.cha_dui('元昊')

# print(dir(Chinese))
# print(Chinese.__dict__) #查看属性字典
print(Chinese.__dict__['dang'])
Chinese.__dict__['sui_di_tu_tan']()
Chinese.__dict__['cha_dui'](1)
# print(Chinese.__name__)
# print(Chinese.__doc__)
# print(Chinese.__module__)

转载于:https://www.cnblogs.com/yikedashuyikexiaocao/p/9327227.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值