不支持的格式字符'?' (0xa)在索引448处

问题描述 投票:-1回答:1

我创建了一个Latex模板,并希望使用字符串占位符来生成表单。

templateB = open('C:/Users/ustjo/Desktop/MM/HSF/HSF-Forms-Generation/template/form-b.tex', 'r').read()

templateB

“\ documentclass [11pt] {book} \ n \ n \ input {preamble.tex} \ n \ n \ begin {document} \ n \ n \ nForm B \ n \ n \ section {扩展香港国际机场三跑道系统} \ n \ n SkyPier高速渡轮的旅行路线和管理计划\ n \ n \ subsection {\ ul {案件审核和检查记录}} \ n \ n {\ renewcommand {\ arraystretch} { 1.4} \ n \开始{表} [HTB] \ n上\字号{11磅} {15pt} \ selectfont \ n \开始{片状} {|> {\ raggedright} p {38毫米} | \ NP {99毫米} <{ \ raggedright} |} \ hline \ n %%% \ n参考计划:和SkyPier高速渡轮的海上旅行路线和管理计划(计划)(EP条件2.10)\ n \\ \ hline \ n监测数据:&渡轮在\ n \ newline \ n \ ul {%(期间)s} \ n \\ [1.0mm] \ hline \ n信息和数据检查期间收集的移动数据:&\ n \ _开始{minipage} [t] { 110mm} \ n \ begin {itemize} \ n \ item自动识别系统(AIS)\ n \ item数据每日SkyPier HSF移动\ n \ item潜在偏差记录\ n \ item由渡轮运营商提供的响应\ n \ end {逐项} \ VSPACE * { - 1.5E x} \ n \ end {minipage} \ n \\\ hline \ n \ nCase No:&\ textit {%(Case No)s} \ n \\ \ hline \ nDate:&\ textit {%(Date)s} \ n \\ \ hline \ nFerry详细信息:&Ferry Number:%(Ferry No)s \ n \ newline平均速度:%(Avg Speed)s knots \ newline瞬时速度范围:%(最小速度)s - %(最大速度s节点\换行瞬时加速持续时间:%(持续时间)s \ n \\ \ hline \ n评论和观察\换行符来自ET:&%(评论)s \\ \ hline \ n评论和观察\来自IEC的新行海事顾问:&\ n \\ \ hline \ nReason(s)有效\\根据\\计划? &\ n \ begin {minipage} [t] {95mm} \ n \ begin {itemize} \ n \ item是(案例结束)\ n \ item [\ nocheck]否(要通过AA MCDD确认所需的ET跟进行动)\ n \ end {itemize} \ vspace * { - 1.5ex} \ n \ end {minipage} \ n \\\ hline \ n \ end {tabular} \ n \ end {table} \ n} \ ñ\ n \ n {\字号{10PT} {12磅} \ selectfont \ n \开始{片状} {:L {23毫米}:L {35毫米}:L {35毫米}:L {35毫米}:} \ n \ hdashline \ n \ Gape [14pt] {}&\ makecell [l] {ET Leader / \\ [2mm] \ nET的代表}&\ n \ makecell [l] {IEC / \\ [2mm] \ nIEC的代表}&\ n \ makecell [l] {PM / \\ [2mm] \ nPM的代表} \\ \ hline \ nSignature&\ includegraphics [scale = 1.0] {sig1.pdf} \ n && \\ \ hdashline \ nName&Terence Kong& &\ n \张口[10PT] {} \ n \\\ hdashline \ n \ {端片状} \ N} \ n \ n \ n \ {端文档} \ n”个

当我尝试运行模板时,使用循环

page = templateB%{'Period':formB.iloc[i,8],'Case No':formB.iloc[i,1], 'Date':formB.iloc[i,2], 
                      'Ferry No':formB.iloc[i,3], 'Avg Speed':formB.iloc[i,4],'Min Speed':formB.iloc[i,5], 
                      'Max Speed':formB.iloc[i,6], 'Duration':formB.iloc[i,7], 'Comments':formB.iloc[i,9]}

它回来了

ValueError                                Traceback (most recent call last)
<ipython-input-7-afe0b30f82bd> in <module>()
      2     page = templateB%{'Period':formB.iloc[i,8],'Case No':formB.iloc[i,1], 'Date':formB.iloc[i,2], 
      3                       'Ferry No':formB.iloc[i,3], 'Avg Speed':formB.iloc[i,4],'Min Speed':formB.iloc[i,5],
----> 4                       'Max Speed':formB.iloc[i,6], 'Duration':formB.iloc[i,7], 'Comments':formB.iloc[i,9]}
      5 
      6     file_name_tex = str(formB.iloc[i,0]) + '.tex'

ValueError: unsupported format character '?' (0xa) at index 448

我只有一个'?'在乳胶中。我试图删除'?'。问题依然存在。

有人可以帮忙吗?

python string python-3.x subprocess latex
1个回答
1
投票

转义不属于替换格式说明符的文字%字符。有些发生在第21行:

%%%

用另一个%角色逃脱每个%,所以这条线将是:

%%%%%%

您必须对文档中的所有文字%字符执行此操作。

© www.soinside.com 2019 - 2024. All rights reserved.