我有这个字符串:
self.assertEquals(ex.user_message,
'''Equalum agent has returned the following error:\nDirectory "{}" doesnt exist.'''
.format(agent_stream['directory']))
我希望将其更改为:
self.assertEquals(ex.user_message,
'''Equalum agent has returned the following error:\nDirectory "{}" doesn't exist.'''
.format(agent_stream['directory']))
我怎么能写而不是在python中没有?
埃雷兹
答案 0 :(得分:1)
例如,您可以使用\'来转义单引号,例如“doesn \'t”。 http://python-reference.readthedocs.io/en/latest/docs/str/escapes.html