Escape for str in Python

前端 未结 6 1506
星月不相逢
星月不相逢 2021-01-25 02:45

Wow, this should be so simple, but it\' just not working. I need to inset a \"\\\" into a string (for a Bash command), but escaping just doesn\'t work.

>>&         


        
6条回答
  •  甜味超标
    2021-01-25 02:53

    'tes\\ting' is correct, but you are viewing the repr output for the string, which will always show escape characters.

    >>> print 'tes\\ting'
    tes\ting
    

提交回复
热议问题