Python3 string.max()方法

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

上一篇: Python3數字 下一篇: Python3字串