擅长:python、mysql、java
<p>如上所述,使用<code>regex</code>更好。但以下条件对你有效。使用<a href="https://docs.python.org/2/library/string.html#string.punctuation" rel="nofollow">string.punctuation</a>计算所有标点符号。你知道吗</p>
<pre><code>import string
while(name.isalnum() or name.isalpha()) and not any(i in string.punctuation for i in name):
</code></pre>