Reputation:
I want to open the calculator program when I type "Open calculator " . I researched a lot , but didn't get the answer I wanted.Can anyone please answer my question.
Upvotes: 0
Views: 164
Reputation: 826
There are 2 ways to do this. One way would be access the cmd using Python which can be done by using os
module. When you try to open the calculator from your command prompt, you probably type calc
. Instead of manually doing this, you can have your Python code do it for you, this is how:
import os
os.system('calc')
The second way is very similar to the first one, except that this method opens another command prompt window so the window in which you're running the python code is not disturbed.
import subprocess
subprocess.Popen("calc",stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL,shell=True)
Upvotes: 1