import subprocess as sp
# windows
windows = "gbk"
# linux
linux = "utf-8"
def exec(cmd, agent) -> None:
p = sp.Popen(cmd, stdout=sp.PIPE, stdin=sp.PIPE, stderr=sp.STDOUT, shell=True)
out, err = p.communicate()
if p.returncode:
print("code: {}, response:{} ".format(p.returncode, out.decode(agent)))
exec("ls -l", linux)