擅长:python、mysql、java
<p>您需要从调用函数发送局部变量作为参数:</p>
<pre><code>def findDist():
if Pro1 == 'alive':
Dist1 = (abs(xYou-xPro1)+abs(yYou-yPro1))
print(Dist1)
if Pro2 == 'alive':
Dist2 = (abs(xYou-xPro2)+abs(yYou-yPro2))
print(Dist2)
if Pro3 == 'alive':
Dist3 = (abs(xYou-xPro3)+abs(yYou-yPro3))
print(Dist3)
if Pro4 == 'alive':
Dist4 = (abs(xYou-xPro4)+abs(yYou-yPro4))
print(Dist4)
if Pro5 == 'alive':
Dist5 = (abs(xYou-xPro5)+abs(yYou-yPro5))
print(Dist5)
if Pro6 == 'alive':
Dist6 = (abs(xYou-xPro6)+abs(yYou-yPro6))
print(Dist6)
findClose(Dist1, Dist2, Dist3, Dist4, Dist5, Dist6)
def findClose(Dist1, Dist2, Dist3, Dist4, Dist5, Dist6):
proDists.extend((Dist1,Dist2,Dist3,Dist4,Dist5,Dist6))
print ("".join(proDists))
</code></pre>