我正在尝试使用YAML格式化python脚本发送的电子邮件,但电子邮件在正文中具有ascii art,而yaml误认为是另一个密钥。如何在密钥内使用特殊字符,如_ /(等等?
这是
MESSAGE:
Dear {santa},
This year you are {santee}'s Secret Santa! Ho Ho Ho!
The maximum spending limit is $50.00
------------------------------------------------------------------
Please Note
------------------------------------------------------------------
This message was automatically generated by secretSanta.py
Do not reply to this email as no one is monitoring the inbox
If there are any questions, comments, concerns, etc please email email@gmail.com
New matches can be generated in the case of extenuating circumstance
Happy Gifting,
TheSecretSantaRobot
_
{_}
/ \
/ \
/_____\
{`_______`}
//[] []\\
(/(__7__)\)
|'-' = `-'|
| |
/\ /\
/ '. .' \
/_/ `"` '\_\
{__}###[_]###{__}
(_/\_________/\_)
|___|___|
|--|--|
(__)`(__)
如果我拿出圣诞老人艺术它发送正常,但我得到一个KeyError,我不知道在哪里放置引号来消除错误
答案 0 :(得分:1)
我认为您希望使用文字标量指示符|
来表示缩进行是单个标量(字符串的YAML用语),其格式应保留:
MESSAGE: |
Dear {santa},
...snip...
_
{_}
/ \
/ \
/_____\
{`_______`}
//[] []\\
(/(__7__)\)
|'-' = `-'|
| |
/\ /\
/ '. .' \
/_/ `"` '\_\
{__}###[_]###{__}
(_/\_________/\_)
|___|___|
|--|--|
(__)`(__)