gpt4 book ai didi

python - 使用 subprocess.Popen 从 python 调用 pandoc

转载 作者:太空宇宙 更新时间:2023-11-03 12:34:08 26 4
gpt4 key购买 nike

我在使用 subprocess.Popen 从 python 调用 pandoc 时遇到问题。这一切都在控制台中工作。这是代码。

# Test markdown file
here is just a simple markdown file.

现在我的 python 代码使用 filename 是我的 markdown 文件的完整路径:

import subprocess
fileout = os.path.splitext(filename)[0] + ".pdf"
args = ['pandoc', filename, '-o', fileout]
subprocess.Popen(args)

我也尝试了各种方法来捕获错误,但都没有用。然而,在控制台中,一切都运行良好:

pandoc '[filename]' -o '[fileout]'

最佳答案

这没有回答您的问题(您可能特别希望/需要使用 subprocess.Popen 调用 pandoc)但是有一个 Pandoc 的 Python 包装器称为 Pyandoc : 看我的回答here .

关于python - 使用 subprocess.Popen 从 python 调用 pandoc,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12649908/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com