如何获取此代码,并获取raw_input并在cmd中添加“ping”,因此在命令提示符中看起来像这样:[ping(raw_input)]
这是代码:
RS_usr = raw_input('input user here: ')
from subprocess import Popen, PIPE, STDOUT
p = Popen(['cmd.exe'], stdout=PIPE, stdin=PIPE, stderr=STDOUT)
out,err = p.communicate(input=RS_usr)
print(out)
答案 0 :(得分:0)
如果我理解正确,你应该在剧本中改变几行:
p = Popen(['cmd.exe', '/k', 'set PROMPT=[Hello, (' + RS_usr + ')]' ], stdout=PIPE, stdin=PIPE, stderr=STDOUT)
out,err = p.communicate()