lua 为什么可以写成require "lpeg?

lua 为什么可以写成require "lpeg


墨色风雨
浏览 1025回答 1
1回答

桃花长相依

你运行lua时,test1.lua和test2.lua是在当前目录下吗?Plain Text code?/tmp/ cat test1.luapackage.path = package.path .. ;./?.lualocal test2 = require(test2)/tmp/ ~/tmp/lua-5.2.2/src/lua test1.lua 没问题/tmp/ rm test2.lua 删掉test2.lua/tmp/ ~/tmp/lua-5.2.2/src/lua test1.lua 报错了/home/user/tmp/lua-5.2.2/src/lua: test1.lua:2: module ;test2; not found:no field package.preload[;test2;]no file ;/usr/local/share/lua/5.2/test2.lua;no file ;/usr/local/share/lua/5.2/test2/init.lua;no file ;/usr/local/lib/lua/5.2/test2.lua;no file ;/usr/local/lib/lua/5.2/test2/init.lua;no file ;./test2.lua;no file ;./test2.lua;no file ;/usr/local/lib/lua/5.2/test2.so;no file ;/usr/local/lib/lua/5.2/loadall.so;no file ;./test2.so;stack traceback:[C]: in function ;require;test1.lua:2: in main chunk[C]: in ?/tmp/ touch test2.lua 重新建立test2.lua/tmp/ ~/tmp/lua-5.2.2/src/lua test1.lua 没问题/tmp/ cd ~/tmp 换到别的目录~/tmp/ ~/tmp/lua-5.2.2/src/lua /tmp/test1.lua 出错了/home/user/tmp/lua-5.2.2/src/lua: /tmp/test1.lua:2: module ;test2; not found:no field package.preload[;test2;]no file ;/usr/local/share/lua/5.2/test2.lua;no file ;/usr/local/share/lua/5.2/test2/init.lua;no file ;/usr/local/lib/lua/5.2/test2.lua;no file ;/usr/local/lib/lua/5.2/test2/init.lua;no file ;./test2.lua;no file ;./test2.lua;no file ;/usr/local/lib/lua/5.2/test2.so;no file ;/usr/local/lib/lua/5.2/loadall.so;no file ;./test2.so;stack traceback:[C]: in function ;require;/tmp/test1.lua:2: in main chunk[C]: in ?
打开App,查看更多内容
随时随地看视频慕课网APP