+ 1
Why isn't the 'timeout' command supported in system()?
Here's the code (in PyCharm, not in SoloLearn): import os os.system("timeout 3") This isn't working; I had thought that a prompt like "Waiting for 3 seconds..." would be shown in the CMD terminal, but it doesn't seem to work. Why is that? According to me, every valid CMD command should be executed if passed as an argument to the system() function. P.S. I know that time.sleep() is an alternative, but that's not the real matter.
7 Answers
+ 2
Your ide may be the problem. One thing is the Window console and another is the window console, because I imagine that it stores your code in a temporary file and it is reading it and putting what I read in an Edit control:
https://www.google.com/amp/s/joseguerreroa.wordpress.com/2016/05/17/como-redirigir-la-escritura-de-la-salida-estandar-por-defecto-consola-en-JUMP_LINK__&&__python__&&__JUMP_LINK-a-un-archivo/amp/
If that's why then you should have trouble running this code:
from os import system;
system("cls");#Clear Screen in windows.
https://code.sololearn.com/cB4FzKc4i7ck/?ref=app
The reason that only learning your code does not work is for the same reason that your IDE cannot show 100% the results of the commands you pass to it.
+ 1
Calvin Thomas What operating system is it?
+ 1
What happens if you try to use the flag / t? Timeout /t <Number>
+ 1
Try running on CMD this code:
python
from os import system as CMD;
CMD("timeout /t 3");
0
Daniel BriceƱo It's Windows 10.
0
Daniel BriceƱo Yup, it works fine now. Thank you!
0
Hello. Instead of using the console, you can do it in python directly. You just have to import the "time" module and call the "sleep" function:
import time;
def timeout(t):
print("Waiting for {} seconds...".format(t));
time.sleep(t);
print("Hola");
timeout(3);
print("Como");
timeout(4);
print("Estas");