python - 为什么不能将 print 函数传递给 python 中的 dir()?

标签 python

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/

相关文章:

python - 如何将 Countvectorized 数据转换回 Python 中的文本数据?

python - xpath <p> 里面 <h3> 空

python - 如何阻止方法内部的警告

python - Numpy 如何推断数组的 dtype

python - 加载 tensorflow 时出错 - 找不到 "cudart64_80.dll"

python - "py.test"与 "pytest"命令

python - pydantic 中有 post_load 吗?

python - 在模块上运行 2to3.py 后仍然存在错误

python - 奇怪的 undefined variable python3

python - Python中人脸识别的Face Anti-Spoofing方法