擅长:python、mysql、java
<p>修改第一个原始输入值。你得到了一根绳子。在</p>
<p>为了获得更好的结果,还需要验证输入:-)</p>
<pre><code>while 1:
firstto=raw_input('How many points do you want to play before it ends? ')
if firstto.isdigit():
firstto = int(firstto)
break
else:
print "Invalid Input. Please try again"
</code></pre>
<p>这将只接受带数字的字符串。即使有人给出的输入是“5.0”,也会被忽略。在</p>
<p>要更好地阅读原始输入,请单击<a href="http://docs.python.org/2/library/functions.html#raw_input" rel="nofollow">here</a>。要了解有关内置字符串方法的更多信息,请阅读<a href="http://docs.python.org/release/2.7.5/library/stdtypes.html#string-methods" rel="nofollow">here</a>。在</p>
<p>附言:这与问题无关。但有一点建议。你的代码可以简化得多。如果您正在学习,请将此代码保留为v0.1并在您的进度时更新它。在</p>