- 帖子
- 24
- 精华
- 0
- 积分
- 122
- 阅读权限
- 20
- 注册时间
- 2017-9-13
- 最后登录
- 2021-2-26
|
from random import randint #取随机数
num = randint(1,10)
print 'who am i'
tim=0
b = False
while b == False:
tim +=1
a=input()
if a > num:
print '%d you big' %a
if a < num:
print 'you small'
if a == num:
b=True
print 'yes'
output=file('result.txt','a')
output.write(tim)
output.close()
这些语句执行到倒数第二步报错
from random import randint #取随机数
num = randint(1,10)
print 'who am i'
tim=0
b = False
while b == False:
tim +=1
a=input()
if a > num:
print '%d you big' %a
if a < num:
print 'you small'
if a == num:
b=True
print 'yes'
result=('%d')%tim
output=file('result.txt','a')
output.write(result)
output.close()
这样就执行成功,请问是为什么
|
|