Python equivalent to Bash: `latexmk file.tex && latexmk -c file.tex`

我的未来我决定 提交于 2019-12-24 13:57:18

问题


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

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


回答1:


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"])


来源:https://stackoverflow.com/questions/15715557/python-equivalent-to-bash-latexmk-file-tex-latexmk-c-file-tex

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!