<p>这是到<a href="http://en.wikibooks.org/wiki/Python_Programming/Variables_and_Strings" rel="nofollow">Wikibooks Python tutorial</a>的链接。我在练习那一页上的“组合数字和字符串”。第一个代码肯定会产生错误(它是在那里写的),但第二个代码也会产生错误:</p>
<pre><code>print ("Please give me a number:",)
response = raw_input()
number = int(response)
Traceback (most recent call last): File "<pyshell#2>", line 1, in <module>
number = int(response) ValueError: invalid literal for int() with base 10: ''
</code></pre>
<p>我好像不知道怎么修理它。
我使用的是python3.3.0,我知道它是input()而不是raw_input()。
请帮忙。在</p>
<p>您正在组合字符串和整数。在</p>
<pre><code>print ("Please give me a number: ")
number = input()
plusTen = int(number) + 10
print ("If we add 10 to your number, we get " + str(plusTen))
</code></pre>
<p>是正确的代码。在</p>