Skip to content

Instantly share code, notes, and snippets.

'''
1 - 2 * ( (60-30 +(-40/5) * (9-2*5/3 + 7 /3*99/4*2998 +10 * 568/14 )) - (-4*3)/ (16-3*2) )
'''
import re
calcStr = "1 - 2 * ( (60-30 +(-40/5) * (9-2*5/3 + 7 /3*99/4*2998 +10 * 568/14 )) - (-4*3)/ (16-3*2) )"
calcStr = re.sub("\ ","",calcStr) # 清除输入中的空格
sepStr = ""
import re
def multiplyDivideFunc(inStr):
outList = list()
if "*" in inStr:
# print("Multiply in inStr")
outList = inStr.split("*")
# print(float(outList[0])*float(outList[1]))
return float(outList[0])*float(outList[1])
elif "/" in inStr:
import re
def multiplyDivideFunc(inStr):
outList = list()
if "*" in inStr:
# print("Multiply in inStr")
outList = inStr.split("*")
# print(float(outList[0])*float(outList[1]))
return float(outList[0])*float(outList[1])
elif "/" in inStr:
@MagicHen25
MagicHen25 / calc.py
Created February 13, 2017 14:35
calc v0.1
'''
1 - 2 * ( (60-30 +(-40/5) * (9-2*5/3 + 7 /3*99/4*2998 +10 * 568/14 )) - (-4*3)/ (16-3*2) )
'''
import re
calcStr = "1 - 2 * ( (60-30 +(-40/5) * (9-2*5/3 + 7 /3*99/4*2998 +10 * 568/14 )) - (-4*3)/ (16-3*2) )"
calcStr = re.sub("\ ","",calcStr) # 清除输入中的空格
sepStr = ""
'''
1 - 2 * ( (60-30 +(-40/5) * (9-2*5/3 + 7 /3*99/4*2998 +10 * 568/14 )) - (-4*3)/ (16-3*2) )
'''
import re
calcStr = "1 - 2 * ( (60-30 +(-40/5) * (9-2*5/3 + 7 /3*99/4*2998 +10 * 568/14 )) - (-4*3)/ (16-3*2) )"
calcStr = re.sub("\ ","",calcStr)