是这样子的:
test1:
import test2
var = 1
def fighting():
while var == 1:
print('战斗开始!')
if test2.my_speed>test2.you_speed:
print('我先攻!砍你一刀!')
x=test2.damage(test2.my_atk,test2.you_def,test2.you_hp)
test2.you_hp = x
print(x)
if x<=0:
print('i win')
break
else:
x=test2.damage(test2.you_atk,test2.my_def,test2.my_hp)
test2.my_hp=x
if x<=0:
print('you win')
break
test2:
my_hp=5;
you_hp=5;
my_atk=3;
you_atk=2;
my_def=1;
you_def=1;
my_speed=3;
you_speed=2;
def damage(_atk,_def,_hp1):
print('造成',_atk-_def,'伤害')
_hp1-=_atk-_def
return _hp1
运行结果是:
F:\Python\python.exe C:/Users/Administrator/PycharmProjects/test/test1.py
Process finished with exit code 0
啥都没有QAQ