import re from re import A # # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param tokens string字符串一维数组 # @return int整型 # class Solution: def evalRPN(self , tokens: List[str]) -> int: # write code here stack = [] for token in tokens: if token in "+-*/": a = stack.pop() b = stack.pop() if token == "+": stack.append(a + b) elif token == "-": stack.append(b - a) elif token == "*": stack.append(a * b) else: stack.append(int(b / a)) else: stack.append(int(token)) return stack[0]