擅长:python、mysql、java
<p>字符串有一个名为<a href="http://docs.python.org/library/stdtypes.html#str.isspace" rel="nofollow">^{<cd1>}</a>的方法,根据文档:</p>
<blockquote>
<p>Return[s] true if there are only whitespace characters in the string and there is at least one character, false otherwise.</p>
</blockquote>
<p>所以,这意味着:</p>
<pre><code>if teststring.isspace():
# contains only whitespace
</code></pre>
<p>会做你想做的。</p>