jmeter安装 jython的插件jar包
通过如下地址下载jython-standalone-XXX.jar包并放到jmeter的XXX\lib\ext目录下面
Downloads | JythonThe Python runtime on the JVMhttps://www.jython.org/download.html

重启jmeter在JSR223中找到jython可以编写python代码执行

python造数据的Faker库
可以根据不同的国家造不同的地址,不同的手机号,不同的名字...
https://faker.readthedocs.io/en/master/#providers

在JSR223中通过java代码调用python
由于Faker是python3.4才开始支持的,所以目前通过JSR223的jython2.7.4无法直接调用所以通过java代码作为中间桥梁进行调用
在JSR223中通过java代码调用python
java
String pyexe = "python";
String pypath = "D:/PythonProject/PythonProject/造数据_faker.py";
String[] strarr = new String[]{pyexe,pypath};
try {
Process process = Runtime.getRuntime().exec(strarr);
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream(),"GB2312"));
String line;
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
reader.close();
int exitVal = process.waitFor();
if (exitVal == 0) {
System.out.println("脚本执行成功");
} else {
System.err.println("脚本执行失败");
}
} catch (Exception e) {
System.out.println(e);
}
