首页 > Python资料 博客日记

Python字符串max()方法

2023-08-14 09:15:48Python资料围观119

文章Python字符串max()方法分享给大家,欢迎收藏Python资料网,专注分享技术知识

Python字符串max()方法从字符串str返回最大字母字符。

语法

以下是max()方法的语法 -

max(str)

参数

  • str - 这是需要从中返回最大字母字符的字符串。

返回值

  • 此方法从给定字符串str中返回最大字母字符。

示例

以下示例显示了max()方法的用法 -

#!/usr/bin/python3

str = "this is a string example....really!!!"
print ("Max character: " + max(str))

str = "this is a string example....wow!!!"
print ("Max character: " + max(str))

当运行上面的程序,它产生以下结果 -

Max character: y
Max character: x

版权声明:本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:jacktools123@163.com进行投诉反馈,一经查实,立即删除!

标签:

相关文章

本站推荐