Aug-22-2019, 04:50 AM
(Aug-22-2019, 04:40 AM)cheers100 Wrote: Hello,
I'm a very beginner of Python. I teach myself Python with videos.
My question is I write an dead loop of while. How should I stop the programme running crazily?
The instructor in the videos say,"for such a case, I should just use "ctrl + c" or go to task manager and select the programme, so I can stop the programme of "while" of loop.
However it didn't work at all with the two ways.
-ctrl +c nothing happen
-task manager: I select the programme, but I fail to kill the programme. The programme is just keeping opening mp3 one after another.
Finally I have to shut down the computer to stop the programme.
The following is the codes I write for your reference only, I don't request you to correct my codes, and other people have to point out that I need to use sleep(), and i = i +1 , etc.
import os i = 1 while i < 8 : fname = 'd:/1/1' + str(i) + '.mp3' os.system(fname)My OS is Windows 7
I tried your script on Windows 10 machine and am abler to stop it with Ctrl+C key combinations
Output:The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
Traceback (most recent call last):
File "deadwhile.py", line 8, in <module>
os.system(fname)
KeyboardInterrupt