以下代码用于检查字符串中的括号是否匹配,横线上应填写( )。 def is_balanced(s): stack = [] for c in s: if c in '([{': stack.append(c) else: if not stack: return False top = stack.pop() if (c == ')' and top !='(') or \ (c == ']' and top != '[') or \ (c == '}' and top != '{'): return False
A:True
B:False
C:return stack
D:return not stack
正确答案:D
试卷来源:202503 CCF-GESP编程能力等级认证Python六级真题