lua的运算符

1、赋值运算符

--赋值
str="helllo".."world"
print(str)
a,b=10,20
print(a,b)
c,d,e=1,2
print(c,d,e)
x,y=4,5,6
print(x,y)

2.算术运算符

--算术运算
a,b=10,20
--加法
c=a+b
print(a.."+"..b.."="..c)
--减法
c=a-b
print(a.."-"..b.."="..c)
--乘法
c=a*b
print(a.."*"..b.."="..c)
--除法
c=a/b
print(a.."/"..b.."="..c)
--求余
c=a%b
print(a.."%"..b.."="..c)
--乘方
c=a^2
print(a.."^2".."="..c)

3.关系运算符

a,b=10,20
print(a>b)
print(a<b)
print(a==b)
print(a~=b)
4.逻辑运算符
--逻辑运算符
print(true and false)
print(true or false)
print(not true) 

4.逻辑运算符

--逻辑运算符

print(true and false)

print(true or false)

print(not true)

5.其它运算符

--其它运算符
str="helloworld"
print(#str)

---恢复内容结束---

猜你喜欢

转载自www.cnblogs.com/alexzhang92/p/10890450.html