2024-10-01 19:22:28 发布
网友
我试图让我的程序在通过一个预定义的函数后打印出分数('9'),但它没有打印出正确的东西
x=8 def score(): globz=x print(globx) globx+=1 return globx x=(score) print(x)
外壳显示:
<'function score at 0x036374F8'>
这不是我想要的。为什么我看到的是这个而不是函数的输出
您没有调用score函数。您看到的值是对函数本身的引用
score
使用score()调用它并在x变量中捕获其返回值:
score()
x
x = score() print(x)
您没有调用
score
函数。您看到的值是对函数本身的引用使用
score()
调用它并在x
变量中捕获其返回值:相关问题 更多 >
编程相关推荐