level 1
迷茫星空17
楼主
源码:
function v(xxx)
local k,v
local i,n=string.find(xxx," ")
k=string.sub(xxx,1,n)
v=string.sub(xxx,i+1,string.len(xxx))
_G[k]=nil
_G[k]=v
print("_G[k]的值",_G[k])
print("改后的值",a)
end
a=200
print("原来的值",a)
v("a 100")
for k,v in pairs(_G) do
print(k,v)
end
输出:
原来的值 200
_G[k]的值 100
改后的值 200
collectgarbage function: 68d16cf0
package table: 00747a00
pcall function: 68d16220
dofile function: 68d172b0
type function: 00746f50
tonumber function: 68d16480
loadfile function: 68d171b0
tostring function: 68d162b0
assert function: 68d17350
next function: 68d16a80
arg table: 007489d8
setmetatable function: 68d16df0
a 200《--------------------------------------------------------------------
string table: 007485f0
io table: 007478e8
debug table: 00748730
print function: 68d16910
xpcall function: 68d16170
os table: 00748848
select function: 68d162f0
rawequal function: 68d168b0
table table: 007478c0
v function: 0074b638
bit32 table: 00748938
utf8 table: 00748a28
coroutine table: 00747758
load function: 68d17090
ipairs function: 68d16fc0
getmetatable function: 68d17240
rawlen function: 68d16840
a 100《--------------------------------------------------------------------
pairs function: 68d16fa0
_G table: 007428d8
error function: 68d16c60
math table: 00748780
_VERSION Lua 5.3
require function: 007477d0
rawset function: 68d16770
rawget function: 68d167e0
值没有改变,有两个a。问题出在哪??
2017年05月13日 06点05分
1
function v(xxx)
local k,v
local i,n=string.find(xxx," ")
k=string.sub(xxx,1,n)
v=string.sub(xxx,i+1,string.len(xxx))
_G[k]=nil
_G[k]=v
print("_G[k]的值",_G[k])
print("改后的值",a)
end
a=200
print("原来的值",a)
v("a 100")
for k,v in pairs(_G) do
print(k,v)
end
输出:
原来的值 200
_G[k]的值 100
改后的值 200
collectgarbage function: 68d16cf0
package table: 00747a00
pcall function: 68d16220
dofile function: 68d172b0
type function: 00746f50
tonumber function: 68d16480
loadfile function: 68d171b0
tostring function: 68d162b0
assert function: 68d17350
next function: 68d16a80
arg table: 007489d8
setmetatable function: 68d16df0
a 200《--------------------------------------------------------------------
string table: 007485f0
io table: 007478e8
debug table: 00748730
print function: 68d16910
xpcall function: 68d16170
os table: 00748848
select function: 68d162f0
rawequal function: 68d168b0
table table: 007478c0
v function: 0074b638
bit32 table: 00748938
utf8 table: 00748a28
coroutine table: 00747758
load function: 68d17090
ipairs function: 68d16fc0
getmetatable function: 68d17240
rawlen function: 68d16840
a 100《--------------------------------------------------------------------
pairs function: 68d16fa0
_G table: 007428d8
error function: 68d16c60
math table: 00748780
_VERSION Lua 5.3
require function: 007477d0
rawset function: 68d16770
rawget function: 68d167e0
值没有改变,有两个a。问题出在哪??