要查找字符串中的字符数,可以使用计数函数。
以下是语法。
(count stringvariable)
参数 - stringvariable,是需要确定字符数的字符串。
返回值 - 字符串中的字符数。
以下是Clojure中字符串格式的示例。
(ns clojure.examples.hello (:gen-class)) (defn hello-Learnfk [] (println (count "Hello"))) (hello-Learnfk)
上面的程序产生以下输出。
5
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)
HarmonyOS快速入门与实战 -〔QCon+案例研习社〕