Chapter3.1 Python函数(1)
来源:互联网 发布:诺基亚500软件 编辑:程序博客网 时间:2024/06/05 07:07
#Python函数
#!/usr/bin/env python# -*- coding:utf-8 -*-#Author:xp#blog_url: http://blog.csdn.net/wuxingpu5/article/details/71209731#Python函数'''定义函数调用函数函数返回值函数参数函数对象函数嵌套名称空间与作用域闭包迭代器''''''内置函数自定义函数无参函数有参函数空函数'''## 语法# def 函数名(参数1,参数2,...):# '''文档注释'''# 函数体# return 值#内置函数# sum()# max()# min()# len()# a = len('hello')# print(a)# b = max(1,2,3)# b = max ([1,2,3])# print(b)#自定义函数# def print_msg():# print('Hello world')# print_msg()#注: 函数需要先定义再使用#==================================================================================================#无参函数#如果函数的功能只是执行一些操作而已,就定义成无参函数#def print_star():# print('#'*6)#有参函数 通常有返回值# x = 10# y = 2# if x > y:# print(x)# else:# print(y)#三元表达式 条件成立的情况下返回左侧的值#res = x if x > y else y#print(res)# def my_max(x,y):# res = x if x > y else y# return res## print(my_max(x,y))#空函数# def auth():# '''认证功能'''# pass# auth()
阅读全文
0 0
- Chapter3.1 Python函数(1)
- [Python入门]Chapter3 函数
- Chapter3.1.1 python函数小示例
- Chapter3.1.4python函数的参数
- chapter3 PL~SQL---1总结
- MFC学习(chapter3;1)
- Beginning Python - Chapter3 : Strings
- Beginning Python Chapter3
- 《算法导论》学习笔记之Chapter3函数的增长 Chapter4.1分治策略
- Chapter3-图像变换-(1)傅里叶变换
- unix环境高级编程.chapter3.1
- python 核心编程Chapter3 Exercise
- Chapter3.1.2 函数的调用
- chapter3
- chapter3
- Windows Via C/C++ Part Ⅰ Chapter3: 内核对象(1)
- Reactive Programming with RxJava-Chapter3:Operators and Transformations(1)
- Chapter3.1 垃圾回收器与内存分配策略一
- Angularjs中select 的ng-repeat 和 ng-options 用法和获取选取值
- JAVA回调机制(CallBack)详解
- jquery 鼠标按住移动的解决方案
- Android EditText设置可以编辑和不可编辑状态
- netstat 具体使用
- Chapter3.1 Python函数(1)
- springboot+freemaker静态化页面
- 制作jffs2根文件系统
- Dijkstra算法讲解(单源最短路径问题求解)
- ts或264通过RTP发送
- html5在手机端调用摄像头的介绍以及新特性
- 使用IntelliJ IDEA开发JavaWeb项目
- 凡是属性中有Set的都直接声明中直接new出来
- LeetCode 111 Minimum Depth of Binary Tree(DFS)