目录

left

该方法根据字符数从字符串的左侧返回子字符串。

语法 (Syntax)

left(str1,number)

参数 (Parameters)

  • str1 - 这是需要从中提取子字符串的字符串。

  • Number - 这是子字符串中需要出现的字符数。

返回值 (Return Value)

根据字符串的左侧和数字返回原始字符串中的子字符串。

例如 (For example)

-module(helloworld). 
-import(string,[left/2]). 
-export([start/0]). 
start() -> 
   Str1 = "hello World", 
   Str2 = left(Str1,2), 
   io:fwrite("~p~n",[Str2]).

输出 (Output)

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

“he”
↑回到顶部↑
WIKI教程 @2018