Py学习  »  Python

如何在python模板中将$作为字符串而不是变量?

nagashree Upadhya • 6 年前 • 2196 次点击  

t1 = Template('rnote over $actor #MintCream \n <$triangle{scale=5}> \n end note')

$triangle被视为一个变量,但我想用它作为一个符号。怎么做的?

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/52705
文章 [ 1 ]  |  最新文章 6 年前
SanV
Reply   •   1 楼
SanV    7 年前

如果我对你的理解正确的话,这就可以做到:

t1 = Template(r'note over $actor #MintCream \n <$triangle{scale=5}> \n end note')

关于 r' , check this