os.date函数定义 原型:os.date ([format [, time]]) 解释:返回一个按format格式化日期.时间的字串或表. lua源码中os.date的注释如下: --- --- Returns a string or a table containing date and time, formatted according --- to the given string `format`. --- --- If the `time` argument is present,…
1.函数定义的格式: Lua使用function定义函数,语法如下: function function_name (arc) --arc表示参数列表,函数的参数列表可以为空 --body end 上面的语法等价于: function_name function_name (arc) --body end_ 上面的方法都是定义了一个全局函数,为了不污染命名空间,同时减少性能损耗,我们应该尽量使用“局部函数”,方法如下(只需要再前面加local声明即可): local function funct…
三元表达式 s = '不下雨' if s == '下雨': print('带伞') if s == '不下雨': print('不带伞') #等效与以下语句 print('带伞' if s == '下雨' else '不带伞') # 三元表达式 函数定义 def login(username,password): #定义login函数 """登陆""" name=input("请输入您的用户名: ").strip() #去除输…
lua os库提供了简单的跟操作系统有关的功能 1.os.clock() 返回程序所运行使用的时间 local nowTime = os.clock() print("now time is ",nowTime) local s = 0 for i = 1,100000000 do s =s+i end spendTime = os.clock() - nowTime print(string.format("Spend time is : %.2f\n", spe…