len
该方法返回特定字符串的长度
语法 (Syntax)
len(str)
参数 (Parameters)
str - 这是需要确定字符数的字符串。
返回值 (Return Value)
返回值是字符串中的字符数。
例如 (For example)
-module(helloworld).
-import(string,[len/1]).
-export([start/0]).
start() ->
Str1 = "This is a string1",
Len1 = len(Str1),
io:fwrite("~p~n",[Len1]).
输出 (Output)
当我们运行上述程序时,我们将得到以下结果。
17