900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > Python max 函数 - Python零基础入门教程

Python max 函数 - Python零基础入门教程

时间:2024-02-14 06:43:06

相关推荐

Python max 函数 - Python零基础入门教程

目录

一.Python max 函数简介二.Python max 函数使用三.猜你喜欢

基础 Python 学习路线推荐 : Python 学习目录 >> Python 基础入门

一.Python max 函数简介

max 函数返回给定参数的最大值,参数可以为序列语法:

# 返回值:返回参数中的最大值;max( x, y, z, .... )

二.Python max 函数使用

# !usr/bin/env python# -*- coding:utf-8 _*-"""@Author:猿说编程@Blog(个人博客地址): @File:Python max 函数.py@Time:/05/09 08:00@Motto:不积跬步无以至千里,不积小流无以成江海,程序人生的精彩需要坚持不懈地积累!"""# max 支持两个或者多个参数,并返回最大值print(max(1,5))print(max(5.5,6100,1,-10,20))'''输出结果:56100'''

注意:max 函数中的类型只能是 int 或者 float 类型,其他类型会报错,例如:

# !usr/bin/env python# -*- coding:utf-8 _*-"""@Author:猿说编程@Blog(个人博客地址): @File:Python max 函数.py@Time:/05/09 08:00@Motto:不积跬步无以至千里,不积小流无以成江海,程序人生的精彩需要坚持不懈地积累!"""print(max(1,'a'))TypeError: '>' not supported between instances of 'str' and 'int'

三.猜你喜欢

Python 条件推导式Python 列表推导式Python 字典推导式Python 不定长参数 *argc/**kargcsPython 匿名函数 lambdaPython return 逻辑判断表达式Python is 和 == 区别Python 可变数据类型和不可变数据类型Python 浅拷贝和深拷贝Python 异常处理Python 线程创建和传参Python 线程互斥锁 LockPython 线程时间 EventPython 线程条件变量 ConditionPython 线程定时器 TimerPython 线程信号量 SemaphorePython 线程障碍对象 BarrierPython 线程队列 Queue – FIFOPython 线程队列 LifoQueue – LIFOPython 线程优先队列 PriorityQueuePython 线程池 ThreadPoolExecutor(一)Python 线程池 ThreadPoolExecutor(二)Python 进程 Process 模块Python 进程 Process 与线程 threading 区别Python 进程间通信 Queue / PipePython 进程池 multiprocessing.PoolPython GIL 锁

未经允许:猿说编程 » Python max 函数

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。