len()方法返回字串的長度。
語法
以下是 len() 方法的語法 -
len( str )
參數
-
NA
返回值
此方法返回字串的長度
示例
下麵的示例演示 len() 方法的使用。
#!/usr/bin/python3 str = "this is string example....wow!!!" print ("Length of the string: ", len(str))
當我們運行上面的程式,會產生以下結果 -
Length of the string: 32