擅长:python、mysql、java
<p>使用<code>replace</code>方法:</p>
<pre><code>myString = myString.replace("\n", "");
</code></pre>
<p>例如:</p>
<pre><code>>>> s = """
test
test
test
"""
>>> s.replace("\n", "")
'testtesttest'
>>> s
'\ntest\ntest\ntest\n' # warning! replace does not alter the original
</code></pre>