怎么解决Shadows name 'total' from outer scope 这问题?

def sums(arg1, arg2):

total = arg1 + arg2
print("函数内 : ", total)
return total

total = sums(10, 20)
print("函数外 : ", total)

“total”那里显示:Shadows name 'total' from outer scope。

图片描述

阅读 10.6k
1 个回答
def sums(arg1, arg2):
    internal_total = arg1 + arg2
    print("函数内 : ", internal_total)
    return internal_total

total = sums(10, 20)
print("函数外 : ", total)
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题