在Spyder中使用Python模块而不是命令行



这里有一个非常初学者的问题。我已经下载了模块";pdf diff";(https://pypi.org/project/pdf-diff/)对于Python,可以让它在终端中执行。但是,我希望在我正在编写的Python脚本中调用该命令。该脚本在for循环中比较多个pdf文件,我希望它为每个文件生成一个pdf差异报告。

如何在Spyder控制台中找到要调用的参数?

谢谢。

当我检查pdf-diff模块时,它似乎只是使用命令行运行。此外,所有者JoshData表示,他不再维护该项目。因此,如果你想在python中使用,你有两个选择:

1-在python中使用bash命令,使用subprocess模块。

2-安装pdf_diff并使用此代码

from pdf_diff import command_line
# 'strike,underline' for style is the default value
# 'png' for format is the default value
# 0 , 100 , 900 for top_margin ,bottom_margin  , width are default values
style = 'strike,underline'.split(',')
format = 'png'
changes = command_line.compute_changes('/path/to/pdf/file/1.pdf', '/path/to/pdf/file/2.pdf',top_margin=0,bottom_margin=100)
img = command_line.render_changes(changes, style, width=900)
img.save('/path/for/saving/name', format.upper())

您应该将其作为一个模块导入Spyder控制台。然后称之为

类似这样的东西:

import pdf-diff
pdf-diff **argument**

最新更新