lua实现php的print的简单介绍

本文目录一览:

lua语言 怎么将信息打印到界面

自己用代码写个打印信息到界面的函数,绑定到lua里,然后在lua里调用。

在Lua中运行print(os.date(“%x”, 906000490)),为什么输出是09/16/1998

你给的格式不对。

os.date ([format [, time]])

If format starts with ‘!’, then the date is formatted in Coordinated Universal Time. After this optional character, if format is the string “*t”, then date returns a table with the following fields: year (four digits), month (1–12), day (1–31), hour (0–23), min (0–59), sec (0–61), wday (weekday, Sunday is 1), yday (day of the year), and isdst (daylight saving flag, a boolean).

If format is not “*t”, then date returns the date as a string, formatted according to the same rules as the C function strftime.

strftime的格式大致如下:

%a Abbreviated weekday name

%A Full weekday name

%b Abbreviated month name

%B Full month name

%c Date and time representation appropriate for locale

%d Day of month as decimal number (01 – 31)

%H Hour in 24-hour format (00 – 23)

%I Hour in 12-hour format (01 – 12)

%j Day of year as decimal number (001 – 366)

%m Month as decimal number (01 – 12)

%M Minute as decimal number (00 – 59)

%p Current locale’s A.M./P.M. indicator for 12-hour clock

%S Second as decimal number (00 – 59)

%U Week of year as decimal number, with Sunday as first day of week (00 – 53)

%w Weekday as decimal number (0 – 6; Sunday is 0)

%W Week of year as decimal number, with Monday as first day of week (00 – 53)

%x Date representation for current locale

%X Time representation for current locale

%y Year without century, as decimal number (00 – 99)

%Y Year with century, as decimal number

%z, %Z Either the time-zone name or time zone abbreviation, depending on registry settings; no characters if time zone is unknown

%% Percent sign

Format code

%#c Long date and time representation, appropriate for current locale. For example: “Tuesday, March 14, 1995, 12:41:29”.

%#x Long date representation, appropriate to current locale. For example: “Tuesday, March 14, 1995”.

%#d, %#H, %#I, %#j, %#m, %#M, %#S, %#U, %#w, %#W, %#y, %#Y Remove leading zeros (if any).

怎么把如下php代码写成lua代码?

base64需要自己找个库调用一下,其他部分实现了,下面是代码

local function decode(str, skey)

   str = str or “”

   skey = skey or “cxphp”

   local replaceStr = string.gsub(str, “O0O0O”, “=”)

   replaceStr = string.gsub(replaceStr, “o000o”, “+”)

   replaceStr = string.gsub(replaceStr, “oo00o”, “/”)

   local strArr  = {}

   local replaceStrLen = string.len(replaceStr)

   for pos = 1, replaceStrLen, 2 do

      local posEnd = math.min(pos + 1, replaceStrLen)

      strArr [#strArr + 1] = string.sub(replaceStr, pos, posEnd)

    end

   local strCount = #strArr

   for key = 1, string.len(skey) do

      local value = string.sub(skey, key, key)

      print(key, value, strArr[key], string.sub(strArr[key], 2, 2))

      if key = strCount and strArr[key] and string.sub(strArr[key], 2, 2) == value then

         strArr[key] = string.sub(strArr[key], 1, 1)

      end

   end

   local needToDecode = table.concat(strArr)

   print(needToDecode)

   — TODO: find a lib base64_decode

end

原创文章,作者:小蓝,如若转载,请注明出处:https://www.506064.com/n/199499.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
小蓝小蓝
上一篇 2024-12-05 10:22
下一篇 2024-12-05 10:22

相关推荐

  • PHP和Python哪个好找工作?

    PHP和Python都是非常流行的编程语言,它们被广泛应用于不同领域的开发中。但是,在考虑择业方向的时候,很多人都会有一个问题:PHP和Python哪个好找工作?这篇文章将从多个方…

    编程 2025-04-29
  • Python简单数学计算

    本文将从多个方面介绍Python的简单数学计算,包括基础运算符、函数、库以及实际应用场景。 一、基础运算符 Python提供了基础的算术运算符,包括加(+)、减(-)、乘(*)、除…

    编程 2025-04-29
  • Python满天星代码:让编程变得更加简单

    本文将从多个方面详细阐述Python满天星代码,为大家介绍它的优点以及如何在编程中使用。无论是刚刚接触编程还是资深程序员,都能从中获得一定的收获。 一、简介 Python满天星代码…

    编程 2025-04-29
  • Python海龟代码简单画图

    本文将介绍如何使用Python的海龟库进行简单画图,并提供相关示例代码。 一、基础用法 使用Python的海龟库,我们可以控制一个小海龟在窗口中移动,并利用它的“画笔”在窗口中绘制…

    编程 2025-04-29
  • PHP怎么接币

    想要在自己的网站或应用中接受比特币等加密货币的支付,就需要对该加密货币拥有一定的了解,并使用对应的API进行开发。本文将从多个方面详细阐述如何使用PHP接受加密货币的支付。 一、环…

    编程 2025-04-29
  • 如何使用Python将print输出到界面?

    在Python中,print是最常用的调试技巧之一。在编写代码时,您可能需要在屏幕上输出一些值、字符串或结果,以便您可以更好地理解并调试代码。因此,在Python中将print输出…

    编程 2025-04-29
  • Python print输出变量

    Python是一种脚本语言,语法简单易懂,目前被广泛应用于数据处理、人工智能、web开发、游戏开发等领域。其中print函数是Python中最常用的函数之一,用于将变量输出到控制台…

    编程 2025-04-28
  • Python设置print颜色

    无论是在学习Python语言还是在实际开发中,输出结果都是非常关键的部分。Python内置的print()函数是最常用的输出方法之一,而如何设置输出结果的颜色,则是开发人员经常遇到…

    编程 2025-04-28
  • Python樱花树代码简单

    本文将对Python樱花树代码进行详细的阐述和讲解,帮助读者更好地理解该代码的实现方法。 一、简介 樱花树是一种图形效果,它的实现方法比较简单。Python中可以通过turtle这…

    编程 2025-04-28
  • 使用PHP foreach遍历有相同属性的值

    本篇文章将介绍如何使用PHP foreach遍历具有相同属性的值,并给出相应的代码示例。 一、基础概念 在讲解如何使用PHP foreach遍历有相同属性的值之前,我们需要先了解几…

    编程 2025-04-28

发表回复

登录后才能评论