该方法根据字符数从字符串的左侧返回子字符串。
left(str1,number)
str1 - 这是需要从中提取子字符串的字符串。
Number - 这是子字符串中需要出现的字符数。
根据字符串的左侧和数字返回原始字符串的子字符串。
-module(helloLearnfk). -import(string,[left/2]). -export([start/0]). start() -> Str1="hello Learnfk", Str2=left(Str1,2), io:fwrite("~p~n",[Str2]).
当我们运行上述程序时,我们将得到以下输出。
“he”
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)