CPython implementation detail: This function relies on Python stack frame support in the interpreter, which isn’t guaranteed to exist in all implementations of Python. If running in an implementation without Python stack frame support this function returns None.
The ^{} module 你有保险吗。只需
import inspect
,然后运行:获取当前执行帧的行号。你知道吗
注意,这是CPython(参考解释器)特有的特性,参见文档:
我不清楚帧的概念和它的行号是否会存在于其他地方,但这在引用解释器上可以很好地工作。有可能这是便携式的(没有其他声明),但我不能确定:
相关问题 更多 >
编程相关推荐