How to print a string without including '\n' in Python

前端 未结 8 998
没有蜡笔的小新
没有蜡笔的小新 2021-01-01 16:26

Suppose my string is:

\' Hai Hello\\nGood eve\\n\'

How do I eliminate the \'\\n\' in between and make a string print like :

8条回答
  •  南方客
    南方客 (楼主)
    2021-01-01 16:35

    Not sure if this is what you're asking for, but you can use the triple-quoted string:

    print """Hey man
    And here's a new line
    
    you can put multiple lines inside this kind of string
    without using \\n"""
    

    Will print:

    Hey man
    And here's a new line
    
    you can put multiple lines inside this kind of string
    without using \n
    

提交回复
热议问题