. - 力扣(LeetCode) 直接解题就行 from typing import List class Solution: def calPoints(self, operations: List[str]) -> int: result_list = [] for item in operations: if item == '+': result_list.append(result_list[-1] + result_list[-2]) elif item == 'D': result_list.append(result_list[-1] * 2) elif item == 'C': result_list.pop() else: result_list.append(int(item)) return sum(result_list)