# py版本感觉更简洁 多学学 defparse(s): num_stack = [] str_stack = [] res = "" num = 0 for c in s: if c.isdigit(): num = num * 10 + int(c) elif c == '(': num_stack.append(num) num = 0 str_stack.append(res) res = "" elif c == ')': temp = res for _ inrange(num_stack.pop() - 1): res += temp res = str_stack.pop() + res else: res += c return res