简单的 *args 函数在 Python 中不起作用

Simple *args function not working in Python

以下收到 "int object is not callable" 错误消息:

def plus(*args):
    return sum(args)

plus(6, 7, 8)

关于为什么的任何想法?这是直接从在线教程会话中获取的,所以我相信其他人也注意到了同样的内容。

谢谢

如果您尝试 print sum,您会看到它打印了一些值。 语法正确(在 Python 3 和 2.7 中)。 错误基本上是说:sum 不能作为函数调用,因为你给它分配了一些不可调用的东西。

测试了您的代码 here and here,并且运行良好