简体   繁体   English

ValueError:不支持的格式字符'

[英]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.

相关问题 ValueError:形成字符串时不支持的格式字符 - ValueError: unsupported format character while forming strings ValueError: 不支持的格式字符 ']' (0x5d) - ValueError: unsupported format character ']' (0x5d) ValueError:mysql scrapy pipline中不支持的格式字符 - ValueError: unsupported format character in mysql scrapy pipline Python,Django:ValueError:索引3处不受支持的格式字符&#39;(&#39;(0x28) - Python, Django: ValueError: unsupported format character '(' (0x28) at index 3 ValueError:索引79处不支持的格式字符&#39;a&#39;(0x61) - ValueError: unsupported format character 'a' (0x61) at index 79 ValueError:定义字典中不支持的格式字符'{'(0x7b) - ValueError: unsupported format character '{' (0x7b) in defining dictionary ValueError:不支持的格式字符&#39;C&#39;(0x43) - ValueError: unsupported format character 'C' (0x43) Python:ValueError:索引1处不支持的格式字符&#39;&#39;&#39;(0x27) - Python: ValueError: unsupported format character ''' (0x27) at index 1 ValueError:索引 650 处不支持的格式字符 &#39;w&#39; (0x77) - ValueError: unsupported format character 'w' (0x77) at index 650 ValueError:索引处不支持的格式字符&#39;{&#39;(0x7b) - ValueError: unsupported format character '{' (0x7b) at index
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM