import subprocess 要传递的参数sn = “your_sn_value”# 构建命令列表,包括文件名和参数command = [“a.bat”, sn]# 执行命令并获取输出process = subprocess.Popen(command, stdout=subprocess.PIPE)output, _ = process.communicate()# 解码输出结果为字符串output = output.decode().strip()print(“BAT 文件的打印输出:”)print(output)# 搜索包含指定片段的行,并提取以其后字符为开始的内容desired_fragment = “D:\cts\…\result\“desired_content = Nonefor line in output.splitlines(): index = line.find(desired_fragment) if index != -1 and line[index + len(desired_fragment):].startswith(”]”): desired_content = line[index + len(desired_fragment):].rstrip("]").strip() break# 打印所需的内容if desired_content: print(“所需内容:”) print(desired_content)else: print(“未找到所需内容”)