<div>
</div>
<p>当我尝试运行此代码时</p>
<pre class="lang-py prettyprint-override"><code>budget = 500
x = 1
y = 1
bet = 0
totalsum = 0
x = input("enter result:")
bet = input("enter bet:")
y = input("you bet on?:")
if x == y:
bet = (bet) * 2
totalsum = budget + bet
budget = totalsum
print("your winnings:", totalsum)
print("your budget:", budget)
if x != y:
totalsum = budget - bet
budget = totalsum
print("your winnings:", totalsum)
print("your budget:", budget)
if budget < 0:
print("you lost :(")
</code></pre>
<p>我得到一个控制台错误:</p>
<blockquote>
<p>Traceback (most recent call last): </p>
<p>File "main.py", line 19, in <br/>
totalsum = budget + bet TypeError: unsupported operand type(s) for +: 'int' and 'str'<br/>
Program finished with exit code 1</p>
</blockquote>
<p>我不明白为什么。这两个值都设置为具有数值,那么为什么其中一个是字符串呢?(我认为这是“str”的意思)</p>