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

前端 未结 8 1018
没有蜡笔的小新
没有蜡笔的小新 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:50

    You can use the replace method:

    >>> a = "1\n2"
    >>> print a
    1
    2
    >>> a = a.replace("\n", " ")
    >>> print a
    1 2
    

提交回复
热议问题