- print("\a"); --bell 硬件滴一聲
- print("a");
- print("\b"); --back space 空格
- print("b");
- print("\f"); --from feed填充表格
- print("\n"); --new line換行
- print("\r"); --carriage reurn返回當前行第一列
- print("\t"); --horizontal tab 水平換行
- print("\v"); --填充表格
- print("\\"); --backslach單斜杠
- print("\""); --double quote雙引號
- print("\'"); --single quote單引號
- print("\["); --left square bracket左中括號
- print("\]"); --right square bracket
- ---------------------------------------------
- print("one line\nnext line\n\"in quote\",\'in quotes\'");
- print("''"); --可以
- --print("" ""); --不可以
- print("\"\""); --必須轉意字符
- ---------------照原樣輸出-----------------------------------
- page = [[
- \n\tttt\nn\yy
- <.>
- <>
- <>
- hh
- ]];
- print(page);
- io.write(page); --用這種方法忽略轉意字符按原樣輸出
- --------------------lua的智能----------------------
- print(10 .. 20); --..操作符必須加空格
- print("10"+1);
- print("10+1");
- line = io.read();
- n= tonumber(line); --將讀入的數據強制轉換為number
- if n == nil then
- error(line .. " is vaild number");
- else
- print(n*2);
- end
- print(tostring(10) == "10");
- print(1 .. 0 == "10");
- print(10 .. "" == "10"); --數字和字符串..為字符串"10"
- print("10"+1 == 11); --數字和字符串+ 為數字11
- print(4 and 5); --第一個為真第二個也為真 則輸出第二個<pre name="code" class="html">a and b -->如果a為false 則返回a 否則返回b
- a or b -->如果a為true則返回a 否則返回b
- and 優先級比 or高
- x = x or v;
- ==>
- if not x then
- x=v;
- end</pre><br>
- <pre></pre>
- <pre name="code" class="plain"><pre></pre>
- <pre></pre>
- </pre>