菜鸟教程 -- 学的不仅是技术,更是梦想!

Python 3 教程
Python3 教程 Python3 简介 Python3 环境搭建 Python3 VScode Python3 基础语法 Python3 基本数据类型 Python3 数据类型转换 Python3 解释器 Python3 注释 Python3 运算符 Python3 数字(Number) Python3 字符串 Python3 列表 Python3 元组 Python3 字典 Python3 集合 Python3 条件控制 Python3 循环语句 Python3 编程第一步 Python3 推导式 Python3 迭代器与生成器 Python3 with Python3 函数 Python3 lambda Python3 装饰器 Python3 数据结构 Python3 模块 Python __name__ Python3 输入和输出 Python3 File Python3 OS Python3 错误和异常 Python3 面向对象 Python3 命名空间/作用域 Python 虚拟环境的创建 Python 类型注解 Python3 标准库概览 Python3 实例 Python 测验

Python3 高级教程

Python3 正则表达式 Python3 CGI编程 Python3 MySQL(mysql-connector) Python3 MySQL(PyMySQL) Python3 网络编程 Python3 SMTP发送邮件 Python3 多线程 Python3 XML 解析 Python3 JSON Python3 日期和时间 Python3 内置函数 Python3 MongoDB Python3 urllib Python uWSGI 安装配置 Python3 pip Python3 operator Python math Python requests Python random Python OpenAI Python 有用的资源 Python AI 绘画 Python statistics Python hashlib Python 量化 Python pyecharts Python selenium 库 Python 爬虫 Python Scrapy 库 Python Markdown Python sys 模块 Python Pickle 模块 Python subprocess 模块 Python queue 模块 Python StringIO 模块 Python logging 模块 Python datetime 模块 Python re 模块 Python csv 模块 Python threading 模块 Python asyncio 模块 Python PyQt Python for 循环 Python while 循环
(追記) (追記ここまで)

Python3 min()方法

Python3 字符串 Python3 字符串


描述

Python min() 方法返回字符串中最小的字母。

语法

min()方法语法:

min(str)

参数

  • str -- 字符串。

返回值

返回字符串中最小的字母。

实例

以下实例展示了min()函数的使用方法:

实例

#!/usr/bin/python3

str = "runoob";
print ("最小字符: " + min(str));

以上实例输出结果如下:

最小字符: b

Python3 字符串 Python3 字符串

AI 思考中...

3 篇笔记 写笔记

  1. #0

    Sakura

    875***[email protected]

    7

    有大写字母的时候,返回是小的大写字符:

    #!/usr/bin/python3
    str = "runoobAa";
    print ("最小字符: " + min(str));

    以上实例输出结果如下:

    最小字符: A

    Sakura

    875***[email protected]

    8年前 (2018年08月07日)
  2. #0

    菜鸟第一步

    597***[email protected]

    16

    max(str)、min(str) 方法不只判断字母,会判断字符串中的所有字符,按照字符在 unicode 中的编码值来决定大小:

    str1 = '12345'
    a = max(str1) # 5
    b = min(str1) # 1
    str1 = 'a哈/'
    a = max(str1) # 哈
    b = min(str1) # /

    菜鸟第一步

    597***[email protected]

    8年前 (2018年08月24日)
  3. #0

    Lanrciodo

    109***[email protected]

    6
    简单的几种比较情况:
    #全为小写英文字母的字符串
    str_alpha = "abcdefghijklmnopqrstuvwxyz"
    #给全小写的字符串加入大写全英文字母的字符串
    str_Alpha = str_alpha + str_alpha.upper()
    #继续给字符串增加数字
    str_all = str_Alpha + "0123456789"
    #分别测试
    print("min(str_alpha):",min(str_alpha))
    print("min(str_Alpha):",min(str_Alpha))
    print("min(str_all):",min(str_all))

    最后输出结果为:

    min(str_alpha): a
    min(str_Alpha): A
    min(str_all): 0

    Lanrciodo

    109***[email protected]

    7年前 (2019年09月04日)

点我分享笔记

  • 昵称 (必填)
  • 邮箱 (必填)
  • 引用地址

AltStyle によって変換されたページ (->オリジナル) /