- 帖子
- 12
- 精华
- 0
- 积分
- 42
- 阅读权限
- 10
- 注册时间
- 2017-8-17
- 最后登录
- 2017-11-1
|
在 L38_module.py 程序中内容如下:
# === 引用其他定义的模块
from L26_football_game_funcation import countsocre
其中 L26_football_game_funcation 为前期测试执行过的程序,内容如下:
from random import choice
direction = ['left','center','right']
def countsocre():
youscore = 0
comscore = 0
for i in range(3):
print ('Please input your shoot dirction from left,center or right')
you = input()
print ('You choice kicked ' + you)
com = choice(direction)
print ('Computer saved ' + com)
if you != com:
print ('Goal!!!')
youscore = youscore + 1
else:
print ('Oops...')
comscore = comscore + 1
if youscore > comscore:
print('Congratulations,You win!!!')
else:
print('Not bad,just lost %d point' % comscore - youscore)
return (youscore,comscore)
l = countsocre()
print ('The socre you : com is %d : %d' % l)
当执行 L38_module.py 的时候,我理解应该仅作countsocre函数,但实际上却是执行了该函数,开始同用户进行了交互,这个情况同调用choice等函数不同,这个是为啥?
|
|