如何使PyCharm在内置函数(如print )上中断?我已经跳到了print的“声明”与Ctrl,并获得了一个PyCharm存根文件:C:\Users\Zvika\AppData\Local\JetBrains\PyCharm2022.1\python_stubs\-185531349\builtins.py
其中包括:
def print(self, *args, sep=' ', end='\n', file=None): # known special case of print
# I've omitted the docstring
pass但是它不是很有用,因为PyCharm不能在pass上放置断点。
你知道我怎么才能破解print吗?
发布于 2022-05-18 09:50:33
如果您仅在调试时需要这样做,那么下面的操作就可以了:
import builtins
def my_breakpoint(*args, **kwargs): # Ingore arguments
breakpoint()
# Redefine `print` builtin
builtins.print = my_breakpoint
print('foo')
# Drops into pdbpython_stubs只是存根,它们提供有关参数和函数返回类型的信息。它们与真正的实现(当然是用C语言)没有任何关系。
https://stackoverflow.com/questions/72286811
复制相似问题