擅长:python、mysql、java
<p>您只有<em>导入</em>函数选择,您仍然需要<em>调用</em>它:</p>
<pre><code>from random import choice # This makes it so we can use the function in the script.
Health = 10
dodge = 1
dmg = 1
hit = dmg + 1
crhit = hit * 2
def fight():
while 1:
mychoice = choice(chances) # We call the function. It gets a random value from the list
if mychoice == hit: # Create an if/elif for each possible outcome
dostuff()
elif ...
fight()
</code></pre>
<p>然后可以使用<code>if/elif</code>结构来处理每个选项</p>
<p>另外,这些<code>global</code>语句也不需要,因为实际上您并没有修改变量本身(除非您打算稍后再修改)。在</p>
<p><code>while 1 == 1</code>可以简单地写成<code>while 1</code>,因为它也可以被认为是<code>True</code>。在</p>