擅长:python、mysql、java
<p><code>str.strip()</code>仅从字符串的<em>开始和结束</em>中删除字符。从<a href="https://docs.python.org/2/library/stdtypes.html#str.strip" rel="noreferrer">^{<cd1>} documentation</a>:</p>
<blockquote>
<p>Return a copy of the string with the <strong>leading and trailing characters</strong> removed. </p>
</blockquote>
<p>强调我的。</p>
<p>使用<a href="https://docs.python.org/2/library/stdtypes.html#str.replace" rel="noreferrer">^{<cd3>}</a>从字符串中的任何位置删除文本:</p>
<pre><code>xxx.replace(',', '')
</code></pre>
<p>对于字符集</em>使用正则表达式:</p>
<pre><code>import re
re.sub(r'[,!?]', '', xxx)
</code></pre>
<p>演示:</p>
<pre><code>>>> xxx = 'hello, world'
>>> xxx.replace(',', '')
'hello world'
</code></pre>