dev-cheats / comments

站点评论仓库
0 stars 1 forks source link

Python 基础之函数 | 开发者秘籍_开发者提升 #115

Open hellokaton opened 6 years ago

hellokaton commented 6 years ago

https://dev-cheats.com/python-full-stack/function.html

函数 函数是 Python 为了代码最大程度的重用和最小化代码冗余而提供的最基本的程序结构。 函数式:将某功能代码封装到函数中,日后便无需重复编写,仅调用函数即可 面向对象:对函数进行分类和封装,让开发“更快更好更强…” 函数式编程最重要的是增强代码的重用性和可读性 创建的函数语法 def 函数名(参数): ... 函数体 ... 返回值 简单的实例 # x为函数的参数 >>> def num(x): ... print(x) ... # 123456等于x >>> num("123456") 123456