---
--格式化金钱数字: 每三位用 , 分割
--
function GD.util_segmentationStr(str)
--求分割总长度
local strLen = string.len(str)
local newStr = ""
--分割符号
local flag = ","
--每3位一分割
for index=0, strLen/3 do
local begin = strLen-2
if begin<0 then begin =0 end
local subStr = string.sub(str,begin,strLen)
strLen = strLen-3
if subStr=="" or index == 0 then
flag = ""
else
flag = ","
end
newStr = subStr..flag..newStr
end
return newStr
end
文章介绍了functionGD.util_segmentationStr函数,用于将金钱数字以每三位分隔的格式进行分割,通过循环和条件判断实现字符串的处理。

1322

被折叠的 条评论
为什么被折叠?



