tôi có hầu hết các mã sau từ đây: Generating pdf-latex with python scriptValueError: nhân vật không được hỗ trợ định dạng '
#!/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__
chạy mã này mang lại cho tôi những lỗi sau:
Traceback (most recent call last):
File "latex.py", line 29, in <module>
content%args.__dict__
ValueError: unsupported format character '
' (0xa) at index 104
ai biết điều gì đang xảy ra sai? Tôi đã có lỗi tương tự từ các phương pháp xoay trang khác.
Nó nói với bạn rằng nó không hỗ trợ linefeeds. – AronVietti
* Ngoài *: chuỗi ký tự cho 'phương trình' có thể là một chuỗi ký tự thô:' equation = r '\ begin ...' '. –
@AronVietti: Nó cho bạn biết rằng '% \ n' không phải là cú pháp định dạng hợp lệ. –