擅长:python、mysql、java
<p>确保使用<code>coins</code>作为<code>global</code>变量:</p>
<pre><code>>>> coins = 0
>>>
>>> def f():
... global coins # <
... coins += 100 # notice also that we're not returning anything
...
>>> f()
>>>
>>> coins
100
</code></pre>