function split( s, c ) for item in string.gmatch( s, "(.-)"..c) do print(item); end end s = "12.12.12.12;122.1111.111.1;"; s2 = "00:00:00-04:00:00;00:00:00-07:00:00;" split( s, ";" ); split( s2, ":" ); 在线测
function count( ... ) return function( ... ) i = i+ return i end end local func = count(...) print(func()) print(func()) print(func()) 结果如下: [Finished .1s] lua 闭合函数:一个函数加上该函数所需访问的所有“非局部变量”. 如上所示:count()函数返回了另一个函数,而这个函数使用了count()函数中的局部变量.当该函数被调用时,coun
一个是分割,一个是连接. 惯例,先看内部帮助文档 Help on method_descriptor: join(...) S.join(iterable) -> string Return a string which is the concatenation of the strings in the iterable. The separator between elements is S. (END) 将可迭代对象(包含的应该是str类型的,不然会报错)连接起来, 返回值是str,用法如