len()方法返回字符串的長度。
語法
以下是len()方法的語法:
len( str )
參數
返回值
此方法返回的字符串的長度。
例子
下面的例子顯示了len()方法的使用。
#!/usr/bin/pythonstr = "this is string example....wow!!!";print "Length of the string: ", len(str);
當我們運行上面的程序,它會產生以下結果:
Length of the string: 32
|
新聞熱點
疑難解答
圖片精選