python - 使用 Python 打开并写入终端
问题描述
我已经阅读了很多关于运行 python 代码的帖子,这些代码可以打开终端并使用以下内容在其中写入:
PIPE_PATH = "/tmp/my_pipe"
if os.path.exists(PIPE_PATH):
os.remove(PIPE_PATH)
os.mkfifo(PIPE_PATH)
# open terminal that reads from your pipe file
#k = subprocess.Popen('ls -la',shell=True)
a = subprocess.Popen(['gnome-terminal', '-e', 'tail --follow {0}'.format(PIPE_PATH)])
message = "JLinkExe -device FE310 -if JTAG -speed 4000 -jtagconf -1,-1 -autoconnect 1\n"
with open(PIPE_PATH, "w") as p:
p.write(message)
由于某种原因,打开的终端是空白终端,有没有办法解决这个问题?在此处输入图像描述
解决方案
推荐阅读
- javascript - 以 JSON 格式显示的内容默认语言环境
- git - 使用 git 交互式 rebase 仅在一组提交中更改作者姓名的风险?
- javascript - 从 SVG 中的路径获取 id
- mysql - 为什么这个sql查询需要很长时间?
- ios - 在 Swift 中请求时具有未知内容的本地通知
- php - 作曲家没有自动加载某些包的问题
- google-chrome - Chrome 无头立即退出 --repl 标志
- vim - 为什么将命令窗口高度设置为 2 行,避免许多不得不“按”的情况
接着说”? - autoit - 自动日期重新格式化
- c - 即使在设置 PATH 变量之后,“gcc 无法识别”。剩下什么?