该方法返回特定字符串的长度

len - 语法

len(str)
  • str   -  这是需要确定字符数的字符串。

len - 返回值

返回值是字符串中的字符数。

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

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

当我们运行上述程序时,我们将得到以下输出。

17

参考链接

https://www.learnfk.com/erlang/erlang-len.html