Python 相当于 Bash:`latexmk file.tex &&Latexmk -c file.tex` [英] Python equivalent to Bash: `latexmk file.tex && latexmk -c file.tex`

查看:29
本文介绍了Python 相当于 Bash:`latexmk file.tex &&Latexmk -c file.tex`的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Xymostech 的帮助下,Bash 中的 && 转换为 Python 的问题已解决,非常感谢他的帮助 -- 谢谢!

The issue of converting && in Bash to Python has been resolved with the assistance of Xymostech, whose help is greatly appreciated -- thank you!

有问题的命令行(来自 Bash 终端)是:latexmk file.tex &&latexmk -c file.tex.

The command line at issue (from the Bash terminal) is: latexmk file.tex && latexmk -c file.tex.

如果有人感兴趣,这里是插件:

Here is the plugin if anyone is interested:

https://github.com/lawlist/ST2-plugin-Latexmk-save-build-clean

推荐答案

&& 是 bash 支持的功能.你可以在 python 中做同样的事情,使用 subprocesscheck_call:

The && is a feature that is supported by bash. You can do the same thing in python though, using subprocess's check_call:

import subprocess

try:
    subprocess.check_call(["latexmk", "file.tex"])
except subprocess.CalledProcessError:
    print "Failed making"
else:
    subprocess.call(["latexmk", "-c", "file.tex"])

这篇关于Python 相当于 Bash:`latexmk file.tex &&Latexmk -c file.tex`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆