Python和Highscore。 [英] Python and Highscore.

查看:109
本文介绍了Python和Highscore。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好!出于教育原因,我一直在用python(仅限文本)制作一个猜猜计算机想到什么号码的游戏。现在,我想在代码中实现一个高分,它会为最好的三个玩家写下名字和尝试次数。首先,我只会告诉你我的游戏,但不要在那个游戏中找到代码:

Hello! I have been making a "guess what number the computer thinks of"-game in python (text-only) for educational reasons. Now, i want to implement a highscore in the code, which writes the best three players with names and number of attempts. First, I''ll just show you my game, but nevermind the code in that one:

< span class =codeLinkonclick =Blur(this,this.parentNode.parentNode,getChildren(this),true);>展开 | 选择 | Wrap | 行号

推荐答案

展开 | 选择 | Wrap | 行号


谢谢:)嗯,首先我需要一个在每个成功结束游戏后写入文件的变量。我该怎么做呢?我是否可以修改游戏脚本,重命名我的所有得分和名称变量,以便它们与HighScore代码中的得分和名称变量匹配?


关于代码:是的,上次我遇到了一些语法错误(块和东西,我很容易修复,还有一个语法错误,得分分数 i-1]和......,不能记住确切的错误,但它是由单词得分引起的语法错误。可能已经未定义得分,尽管第一行之一定义scres by:scores = [0,0,0]。无论如何,你的修复似乎解决了这个问题。
Thank you:) Well, first of all i need a variable that writes to file after each successfully ended game. How do I do this? Can I just modify the game script, renaming all my score and name variables so they match with the variables for score and names in the HighScore code?


About the code: Yeah, last time i got some syntax errors (blocks and stuff, which I fixed easily, and one syntax error for "while score scores[i-1] and...", cant remember the exact error, but it was a syntax error caused by the word "scores". Might have been "scores is not defined", although one of the first lines defines scres by: scores = [0,0,0]. Anyways, your fixes seems to have fixed the problem.



我可以修改游戏脚本,重命名我的所有得分和名称变量,使它们与HighScore代码中的得分和名称变量匹配?
Can I just modify the game script, renaming all my score and name variables so they match with the variables for score and names in the HighScore code?



没必要,因为高分代码就是所有函数。只要你传递正确的值,你就会达到理想的结果

Not necessary, since the high score code is all functions. As long as you''re passing the correct values, you will achieve the desired result


这篇关于Python和Highscore。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆