版权声明:学习交流为主,未经博主同意禁止转载,禁止用于商用。 https://blog.csdn.net/u012965373/article/details/89091292
# -*- coding:utf-8 -*-
__author__ = 'yangxin_ryan'
import subprocess
import chardet
import sys
class ExecJar(object):
def run(self, source_path, sheet_id, start_point, end_point):
command = "java -jar /xxxx.jar"
cmd = [command, source_path, sheet_id, start_point, end_point]
new_cmd = " ".join(cmd)
stdout,stderr = subprocess.Popen(new_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
encoding = chardet.detect(stdout)["encoding"]
result = stdout.decode(encoding)
return result
if __name__ == '__main__':
exec_jar = ExecJar()
exec_jar.run("/xxxxxx", 0, "xxx", "xxx")