擅长:python、mysql、java
<p>您可能正在使用Python 2.x,其中<code>input</code>将<code>eval</code>用户输入。仅在Python 3.x中<code>input()</code>返回原始用户输入。</p>
<p>您可以通过在控制台中运行<code>python</code>来检查Python的版本,例如这是Python 2.6:</p>
<pre><code>~$ python
Python 2.6.5 (r265:79063, Apr 5 2010, 00:18:33)
[GCC 4.2.1 (Apple Inc. build 5659)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
</code></pre>
<p>您可以通过<code>python3.1</code>运行特定版本的Python(例如3.1):</p>
<pre><code>~$ python3.1
Python 3.1.1 (r311:74480, Jan 25 2010, 15:23:53)
[GCC 4.2.1 (Apple Inc. build 5646) (dot 1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
</code></pre>