class Solution(object):
def foo(self, s):
def bar(a):
s += a
print s
bar("aa")
Solution().foo("ss")
运行结果
UnboundLocalError: local variable 's' referenced before assignment
class Solution(object):
def foo(self, s):
def bar(a):
print s
bar("aa")
Solution().foo("ss")
运行结果ss