函数和其他对象没有单独的命名空间。如果你写def name1(name2): print(name2)您创建类型的实例function,然后将该实例分配给名称name1。(def语句只是一种非常奇特的赋值语句。)参数名是局部变量,属于函数定义的范围,而不是函数定义的范围。这意味着您可以重复使用该名称,但不建议这样做,因为它可能会造成混淆。 belongs to the scope in which the function is defined | | +--- belongs to the scope inside the function | | v vdef name(name): print(name)然而,下面的任务name = 'arjun'与函数定义在同一作用域内,因此 thisname引用了一个str对象,而不是function它过去引用的对象。