擅长:python、mysql、java
<p>内置的<a href="https://docs.python.org/2/library/stdtypes.html#str.partition">^{<cd1>}</a>方法将为您执行此操作。与<a href="https://docs.python.org/2/library/stdtypes.html#str.split">^{<cd2>}</a>不同的是,它不会费心将<code>str</code>的其余部分切割成不同的<code>str</code>s</p>
<pre><code>text = raw_input("Type something:")
left_text = text.partition("!")[0]
</code></pre>