在python中调用pandoc的问题。提供“V args”不起作用

2024-05-19 02:53:16 发布

您现在位置:Python中文网/ 问答频道 /正文

当我用“-V args”调用pandoc时,例如:'-V title=“Wartość”' 在Python脚本中,我得到的输出没有标题..:(

示例: 手动输入pandoca命令(终端):

/usr/bin/pandoc  /home/user/program/content.md -V title="Wartość" 
-V authors="Jerry" --output=/home/user/program/outputs/book_22.pdf

有效:) 输出文件:pandoc output when use manually pandoc in the terminal

但是当我在python中运行相同的命令时(调用pandoc):

 subprocess.call(['/usr/bin/pandoc', '/home/user/program/content.md', '-V title="Wartość", -V authors="Jerry" ', '--output=/home/user/program/outputs/book_33.pdf'])

输出文件:pandoc output when I call to him from python script

如何修复?你知道吗


Tags: 命令homeoutputbintitleusrcontentprogram
1条回答
网友
1楼 · 发布于 2024-05-19 02:53:16

假设您在Python中运行“同一命令”是不正确的。当参数应该分开时,可以将它们组合成单个字符串。你知道吗

subprocess.call(['/usr/bin/pandoc', '/home/user/program/content.md',
    '-V',  'title="Wartość"', '-V', 'authors="Jerry"', 
    ' output=/home/user/program/outputs/book_33.pdf'])

将命令行转换为适合subprocess.call()的列表的简单方法是shlex.split()。你知道吗

相关问题 更多 >

    热门问题