• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

yxchun

  • 博客园
  • 联系
  • 订阅
  • 管理

公告

View Post

jmeter 调用 python代码

1、添加计数器

 

 

2、创建BeanShell 取样器

 

 3、BeanShell 取样器内容如下

 

import java.io.BufferedReader;
import java.io.InputStreamReader;

//python 路径 C://Users//chun//Desktop//FAPlus//auto//ymxia1test//test04.py

// 传递参数:-t ${deviceNUM}

String command = "cmd /c python C://Users//chun//Desktop//FAPlus//auto//ymxia1test//test04.py -t ${deviceNUM}";
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec(command);
//等待执行
pr.waitFor();
//读取python打印到控制台的内容
BufferedReader b = new BufferedReader(new InputStreamReader(pr.getInputStream()));
String line = "";
StringBuilder response = new StringBuilder();

//一行行读取
while ((line = b.readLine()) != null) {
response.append(line);
}


String response_data = response.toString();
//将数据打印到控制台
System.out.println("response_data="+response_data);
b.close();

posted on 2022-03-26 18:35  yxchun  阅读(255)  评论(0)    收藏  举报

刷新页面返回顶部
 
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3