python是否可以打开一个终端并对其进行写入? [英] Is it possible to have python open a terminal and write to it?
本文介绍了python是否可以打开一个终端并对其进行写入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如,如果我有以下代码:
For example, if I have this code:
subprocess.call(['gnome-terminal'])
是否可以将python输出字符串输出到刚打开的特定终端?谢谢!
Is it possible to have python output strings to that specific terminal that was just opened? Thanks!
推荐答案
Possibly, but it is easier to have a custom process running in the subordinate terminal. For example, given sserv.py
from the example server in the documentation the command:
gnome-terminal -e "python ./sserv.py"
将很高兴在端口9999上与您聊天.给定一个更复杂的 sserv.py
,它可以做任何您想做的事情(就是卑鄙的事).
will happily chat on port 9999 with you. Given a more complex sserv.py
it could do anything you want (anything terminalish, that is).
这篇关于python是否可以打开一个终端并对其进行写入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文