[英]ValueError: unsupported format character '
I got most of the following code from here: Generating pdf-latex with python script 我从这里获得了以下大部分代码: 使用python脚本生成pdf-latex
#!/usr/bin/env python
from __future__ import division
from functions import *
import shlex
#from Utilities import *
import os
import argparse
import subprocess
equation = '\begin{equation*}1 + \gamma\lambda B/2\end{equation*}'
content=r'''\documentclass{article}
\usepackage{graphicx,amsmath}
\begin{document}
\noindent\rotatebox{180}{\vbox{%
%(equation)s
}%
}
\end{document}
'''
parser=argparse.ArgumentParser()
parser.add_argument('-e', '--equation', default=equation)
args=parser.parse_args()
content%args.__dict__
print content%args.__dict__
running this code gives me the following error: 运行此代码会给我以下错误:
Traceback (most recent call last):
File "latex.py", line 29, in <module>
content%args.__dict__
ValueError: unsupported format character '
' (0xa) at index 104
anybody know what's going wrong? 谁知道出了什么问题? I've got the same error from other methods of rotating the page.
我从其他旋转页面的方法中得到了同样的错误。
Any %
in content
is seen as a formatting placeholder. content
任何 %
都被视为格式化占位符。 Double any that are not a placeholder: 将任何非占位符加倍:
content=r'''\documentclass{article}
\usepackage{graphicx,amsmath}
\begin{document}
\noindent\rotatebox{180}{\vbox{%%
%(equation)s
}%%
}
\end{document}
'''
Otherwise the %
at the end of the \\noindent\\rotatebox{180}{\\vbox{%
line is seen together with the \\n
newline as a formatting character, hence the exception with an embedded newline. 否则,
\\noindent\\rotatebox{180}{\\vbox{%
末尾的%
\\noindent\\rotatebox{180}{\\vbox{%
line与\\n
换行符一起被视为格式化字符,因此带有嵌入换行符的异常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.