fix bc bug

This commit is contained in:
weilinfox 2020-03-07 18:45:44 +08:00
parent 8087c72cb4
commit 212d47b93f

View file

@ -365,13 +365,10 @@ def funMain (ch):
def sysbc (arg): def sysbc (arg):
try: try:
arg = "echo \"" + arg + "\" | bc" arg = arg.replace("\'", "")
ret = subprocess.run(arg, shell = True, stdout = subprocess.PIPE, stderr = subprocess.STDOUT, check = True, timeout = 2) arg = "echo \'\'\'" + arg + "\'\'\' | bc"
retmes = str(ret.stdout) ret = subprocess.run(arg, shell = True, stdout = subprocess.PIPE, stderr = subprocess.STDOUT, check = True, timeout = 1)
retmes = retmes[2:len(retmes)-3] return bytes.decode(ret.stdout).replace("\n", "")
retmes = retmes.replace('\\n', ". ")
retmes = retmes.replace('\\', "")
return retmes
except subprocess.TimeoutExpired: except subprocess.TimeoutExpired:
return "你干了啥怎么半天算不完啦!服务器爆了打你哦~" return "你干了啥怎么半天算不完啦!服务器爆了打你哦~"
except: except: