Remove all line breaks from a long string of text

前端 未结 8 1924
长发绾君心
长发绾君心 2020-11-28 19:53

Basically, I\'m asking the user to input a string of text into the console, but the string is very long and includes many line breaks. How would I take the user\'s string a

8条回答
  •  眼角桃花
    2020-11-28 20:45

    If anybody decides to use replace, you should try r'\n' instead '\n'

    mystring = mystring.replace(r'\n', ' ').replace(r'\r', '')
    

提交回复
热议问题