设为首页收藏本站

Crossin的编程教室

 找回密码
 立即加入
查看: 11206|回复: 2
打印 上一主题 下一主题

游戏的第一个,也是报错,求大佬指导

[复制链接]

4

主题

0

好友

34

积分

新手上路

Rank: 1

跳转到指定楼层
楼主
发表于 2018-2-27 21:44:55 |只看该作者 |倒序浏览
本帖最后由 冬天吃冰棍儿 于 2018-2-27 21:46 编辑

f=open(r'D:\py\game0227\game.txt')
save=f.read().split()
print(save)
game_times=int(save[0])
min_times=int(save[1])
total_times=int(save[2])
if game_times!=0:
    ave_times=float(total_times)/game_times
else:
    ave_times=0
print('you have won %d times,and min_times is %d,ave_times is %.2f'(
    game_times,min_times,ave_times)   )

错误
#Traceback (most recent call last):
  File "D:/py/game0227/test.py", line 15, in <module>
    game_times,min_times,ave_times)   )
TypeError: 'str' object is not callable

回复

使用道具 举报

6

主题

2

好友

654

积分

实习版主

Rank: 7Rank: 7Rank: 7

沙发
发表于 2018-2-28 08:48:25 |只看该作者
按报错信息看 是第15行那个print('string%d and %d and %d' % (1,2,3))的结构,你把中间的%漏掉了
回复

使用道具 举报

4

主题

0

好友

34

积分

新手上路

Rank: 1

板凳
发表于 2018-2-28 14:56:42 |只看该作者
TED 发表于 2018-2-28 08:48
按报错信息看 是第15行那个print('string%d and %d and %d' % (1,2,3))的结构,你把中间的%漏掉了 ...

哎呀 真的是这样的 已经运行出来啦 谢谢
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即加入

QQ|手机版|Archiver|Crossin的编程教室 ( 苏ICP备15063769号  

GMT+8, 2024-4-28 07:09 , Processed in 0.024001 second(s), 21 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

回顶部