print 是内置函数吗?如果是,为什么我不能运行 dir(print)
? dir
是一个内置函数,dir(dir)
运行良好。所以对我来说,dir(print)
无法工作看起来很奇怪。
最佳答案
在 python 2 中,print 是语句而不是函数,你不能将语句作为函数参数,另一方面在 python3 print is a function 中所以你可以做dir(print)
。
关于python - 为什么不能将 print 函数传递给 python 中的 dir()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7472218/