[英]How do I execute a python file beginning in a specific code line?
I have a simulation in python which I have run, but half way to the end I got an error. 我已经在python中运行了一个模拟,但是到最后一半我遇到了一个错误。 I have already fixed the error.
我已经解决了错误。 Now I want to execute the same file, but beginning in the line of the error.
现在,我想执行相同的文件,但从错误所在的行开始。 How can I do that?
我怎样才能做到这一点? Execfile, as far as I looked doesn't do that...
就我看来,Execfile并没有这样做...
You don't. 你不知道
The easiest solution would be to comment out all the intervening lines, or put them inside an if False:
block. 最简单的解决方案是注释掉所有中间的行,或将它们放入
if False:
块中。
You could also simply save the appropriate portion of the code into a new file and run that instead. 您也可以简单地将代码的适当部分保存到新文件中,然后运行该文件。
Any of these operations should be trivial in most editors. 这些操作中的任何一个在大多数编辑器中都是微不足道的。
put the line in a class then just call that class. 将该行放在一个类中,然后只需调用该类即可。 This is what I would do rather than commenting out the lines..
这是我要做的,而不是注释掉界线。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.