QuickLuaTour翻譯流水賬 11 20

2021-09-01 08:15:12 字數 3328 閱讀 9245

-- example 11  -- numbers.

-- multiple assignment showing different number format.

-- two dots (..) are used to concatenate strings (or a

-- string and a number).

a,b,c,d,e = 1, 1.123. 1e9, -123, .0008

print("a="..a, "b="..b, "c="..c, "d="..d, "e="..e)

------ output ------

a=1 b=1.123 c=1000000000 d=-123 e=0.0008

-- 例子 11 -- 數字

-- 以下多個賦值語句說明了不同的數字格式。

-- 兩個點號被用來連線字串(也可連線乙個字串和乙個數字)

-- example 12 -- more output.

-- more writing output.

print "hello from lua!"

print("hello from lua!")

------ output ------

hello from lua!

hello from lua!

-- 例子 12 -- 更多的輸出

-- example 13 -- more output.

-- io.write writes to stdout but without new line.

io.write("hello from lua!")

io.write("hello from lua!")

-- use an empty print to write a single new line.

print()

------ output -------

hello from lua!hello from lua!

-- 例子13 -- 更多的輸出

-- io.write可以寫控制台,但不會換行

-- print()可以列印乙個空行

-- example 14 -- tables.

-- ****** table creation.

a={} -- {} creates an empty table

b= -- creates a table containing numbers 1,2,3

c= -- creates a table containing strings a,b,c

print(a,b,c) -- tables don't print directly, we'll get back to this!!

------- output -------

table:009eb468 table:009eb558 table:009eb580

-- 例子 14 -- 表

-- 簡單的建立表

a={} -- {}建立乙個空表

b= -- 建立乙個包含數字1,2,3的表

c= -- 建立乙個包含串a,b,c的表

print(a,b,c) -- 不能直接的列印表,我們會回來搞定這個問題!!

-- example 15 -- more tables.

-- associate index style.

address={} -- empty address

address.street="wyman street"

address.streetnumber=360

address.aptnumber="2a"

address.city="watertown"

address.state="vermont"

address.country="usa"

print(address.streetnumber, address["aptnumber"])

------ output ------

360 2a

-- 例子 15 -- 表續集

-- 關聯,索引風格

-- example 16 -- if statement.

-- ****** if.

a=1if a == 1 then

print(a is one)

end------ output -------

a is one

-- 例子 16 -- if語句

-- 簡單的if

-- example 17 -- if else statement.

if b=="sad" then

print("b is sad")

else

print("b is not sad")

end------ output ------

b is not sad

-- 例子 17 -- if else 語句

-- example 18 -- if elseif else statement

c=3if c==1 then

print("c is 1")

elseif c==2 then

print("c is 2")

else

print("c isn't 1 or 2, c is "..tostring(c))

end------ output -------

c isn't 1 or 2, c is 3

-- example 19 -- conditional assignment.

-- value = test and x or y

a=1b=(a==1) and "one" or "not one"

print(b)

-- is equivalent to

a=1if a==1 then

b = "one"

else

b= "not one"

endprint(b)

------ output ------

oneone

-- 例子 19 -- 條件賦值

-- example 20 -- while statement

a=1while a~=5 do -- lua uses ~= to mean not equal

a=a+1

io.write(a.." ")

end------ output -------

2 3 4 5

-- 例子20 -- while語句

-- lua使用~=來表示不等於

QuickLuaTour翻譯流水賬 21 30

example 21 repeat until statement.a 0repeat a a 1 print a until a 5 output 12 345 例子 25 repeat until 語句 example 22 for statement numeric iteration for...

OTL翻譯 10 OTL的流緩衝池

otl的流緩衝池 一般來講,流一般作為乙個區域性的變數被使用,當使用完畢後就立刻關閉,如果需要再次使用就需要再次的宣告變數,如此迴圈。otl流的緩衝池 記憶體池 是乙個解決以往的流效能低下的乙個機制。當流被關閉後,實際上流的相關變數被儲存在乙個流緩衝池裡面,以便再利用。每乙個流在解析sql或與資料庫...

python翻譯 Python翻譯

translator.py coding utf 8 author inspurer 月小水長 pc type lenovo create time 2019 4 6 15 44 file name translator.py github qq郵箱 2391527690 qq.com import...