Erlang - 長度



該方法返回特定字串的長度

語法

len(str)

引數

  • str − 這是需要確定字元數的字串。

返回值

返回值是字串中的字元數。

例如

-module(helloworld). 
-import(string,[len/1]). 
-export([start/0]). 

start() -> 
   Str1 = "This is a string1", 
   Len1 = len(Str1), 
   io:fwrite("~p~n",[Len1]).

輸出

當我們執行上述程式時,我們將得到以下結果。

17
strings.htm
廣告
© . All rights reserved.