'''
面向过程:
核心'过程'
过程的核心思想是将程序流程化
过程是'流水线',用来分步骤解决问题
面向对象:
核心'对象'
对象的核心思想是将程序"整合"
对象是"容器", 用来存放数据和功能的
python提供了固定语法来允许将数据和功能很好地整合到一起
'''
# 程序 = 数据 + 功能
# 学生的容器 = 学生的数据 + 学生的功能
# 课程的容器 = 课程的数据 + 课程的功能
# # 学生数据
# stu_name = 'egon'
# stu_age = 18
# stu_gender = 'male'
# 学生的功能
def tell_stu_info(stu_obj):
print('学生信息:名字:{} 年龄:{} 性别:{}'.format(
stu_obj['stu_name'],
stu_obj['stu_age'],
stu_obj['stu_gender'],
))
def set_info(stu_obj, x, y, z):
stu_obj['stu_name'] = x
stu_obj['stu_age'] = y
stu_obj['stu_gender'] = z
# 用字典将数据和功能整合到一起(面向对象编程思想)
stu_obj = {
'stu_name': 'egon',
'stu_age': 18,
'stu_gender': 'male',
'tell_stu_info': tell_stu_info,
'set_info': set_info
}
# 课程的数据
course_name = 'python'
course_persiod = '6mons'
course_score = 10
def tell_coure_info():
print('课程信息:名字:{} 周期:{} 学分:{}'.format(course_name, course_persiod, course_score))