eval
赛高!我的最爱!直接把出题人卡你的地方手动改掉即可。
def deal(a): a = a.replace('^','**') a = a.replace(' ','') a = a.replace('()','') a = a.replace('/','//') #注意整除 cnt = 0 r = [] for i in range(len(a)): if a[i] == '(': cnt+=1 elif a[i] == ')': if cnt == 0: r.append(i) else: cnt-=1 la = list(a) for i in r: la.pop(i) n = len(la) cnt = 0 l = [] for i in range(n): if la[n - 1 - i] == ')': cnt+=1 elif la[n - 1 - i] == '(': if cnt == 0: l.append(n - 1 - i) else: cnt-=1 for i in l: la.pop(i) a = ''.join(la) return a s = input() s = deal(s) print(eval(s))