Python字符串max()方法

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

上一篇: Python字符串 下一篇: Python列表