+ 1
Type in Command prompt
So I can open Command prompt with python code, but is there a way to have pythons code type in Command prompt ? - Thanks
7 Réponses
+ 1
You can use 'python' or 'py'.
https://stackoverflow.com/questions/13596505/python-not-working-in-command-prompt/47869909
Read about here.
+ 1
I think understand your question, you would like to be able to open the cmdline, using Python, and have Python send commands to the cmdline? If so, "subprocess" is a preferred library:
import subprocess
cmd=['echo hello', 'dir']
for each in cmd:
process=subprocess.Popen(each,stdout=subprocess.PIPE,shell=True)
output=process.communicate()[0]
print(output.decode('utf-8'))
That should print out cleaner
0
no, I need to open and type in command prompt automated using python.
0
You can refer to a python file using the command above, run what you want, and then continue. The user must have Python modules though.
0
I know, that isnt the problem, I need to type in command prompt. like if I were typing in it, but it's the code.
0
okay, alexander's code worked, but here is my question : Is there anything else I can type into it ?
- Thanks again
0
and is there a way you can open command prompt and type in it, and open files ?