擅长:python、mysql、java
<p>为了你的第一次检查</p>
<pre><code>import string
if len(name) > 10 or any(l not in string.ascii_letters for l in name):
# reject
</code></pre>
<p>第二次</p>
^{pr2}$
<p>或者你可以做一些更复杂的事情:</p>
<pre><code>def validate_class(cls):
if (len(cls) != 3 or
int(cls[0]) not in [5, 6] or
cls[1] not in ["A", "B", "C"] or
int(cls[2]) not in [1, 2]):
return False
return True
</code></pre>
<p>这表示了一个关于有效类<code>cls</code>是什么的更一般的规则。在</p>