擅长:python、mysql、java
<p>在Python文档中,<a href="https://docs.python.org/2/library/stdtypes.html" rel="nofollow">https://docs.python.org/2/library/stdtypes.html</a>对于序列:</p>
<pre><code>x in s True if an item of s is equal to x, else False (1)
x not in s False if an item of s is equal to x, else True (1)
(1) When s is a string or Unicode string object the in and not in operations act like a substring test.
</code></pre>
<p>对于用户定义的类,<code>__contains__</code>方法实现这个<code>in</code>测试。<code>list</code>和<code>tuple</code>实现了基本概念。<code>string</code>增加了“substring”的概念。<code>string</code>是基本序列中的一个特例。你知道吗</p>