我有一个现成的PDF文档,其中包含某些区域的占位符值.
例如{{first_name}},{{postcode}},...
我需要使用python替换这些值.
有什么建议?
你可以使用马科。
from mako.template import Template
template = Template(filename='template.pdf')
output = Template.render(first_name='Simon', postcode='12345')
Run Code Online (Sandbox Code Playgroud)
我忘了提及,在本例中,Mako 模板的默认值将使用 ${first_name} 和 ${postcode}。我不确定这是否可以改变。