freeCodeCamp/guide/chinese/elixir/strings/index.md

797 B
Raw Blame History

title localeTitle
Strings 字符串

字符串

Elixir中的字符串用双引号括起来而字符列表是单引号。它们是UTF-8编码的二进制文件。

iex> "Hello world!" 
 "Hello world!" 

字符串插值可以在Elixir中使用octothorp然后是花括号。

iex> variable = "world!" 
 "world!" 
 iex> "Hello #{variable}" 
 "Hello world!" 

String模块包含许多基于Unicode标准的有用内置函数。

iex> example = "string" 
 "string" 
 iex> String.capitalize(example) 
 "String" 
 iex> String.duplicate(example, 2) 
 "stringstring" 

更多信息: