a.lua和b.lua在同一个目录下 a.lua调用b.lua中的test方法,注意b中test的写法 _M 和 a中调用方法: b.lua local _M = {}function _M.test() ngx.say("hello test!")endreturn _M a.lua local test = require("b")if not test then ngx.say("Failed to require b!")
在工作当中经常遇到反编译后的jar文件,并要传入参数了解其中的某些方法的输出,想到Java里面的反射可以实现加载jar文件并调用其中的方法来达到自己的目的.就写了个Demo代码. 以下的类可以编译生成hello.jar文件. package org.lele.fatpanda; public class Util { public static String myName; /* * 无参数,无返回值的方法. */ public static void getVersion() { System
假设名为A.py的文件需要调用B.py文件内的C(x,y)函数 假如在同一目录下,则只需 import B if __name__ == "__main__": B.C(x,y) 若只需调用单个函数,也可以 from B import C if __name__ == "__main__": C(x,y) 若A.py和B.py位于不同的目录下,可以用以下方法 (假设B.py位于D盘的根目录下) 1.引用所在路径 import sys sys.path.append(