Normally to force stop python script that are running, we normal just press Ctrl + C (in Interactive console). In this case, it does not stop, when I press Ctrl + C. Here is my code for this situation:
JavaScript
x
9
1
import datetime
2
from datetime import timedelta
3
x = datetime.datetime.now()
4
print(x)
5
i=0
6
while (datetime.datetime.now()<x + timedelta(seconds=20) ):
7
print(i)
8
i=i+1
9
I want it to force it to stop before the 20seconds is reached.
Please help explain why this happened and help find a solution to this.
Advertisement
Answer
It’s just you. It accepted the KeyboardInterrupt for me.