[英]How to create a leader board in repl.it python
I'm trying to make a game with a leaderboard, and I have the code that writes the high scores in a file, but when multiple people play the game, they have separate leaderboards.我正在尝试使用排行榜制作游戏,并且我有将高分写入文件的代码,但是当多人玩游戏时,他们有单独的排行榜。 so basically, i'm asking if there's a way to have everyone share a file in repl.it.
所以基本上,我在问是否有办法让每个人在 repl.it 中共享一个文件。
If your code is writing to local files eg via open('some_file.txt')
, then those are limited to the individual user's Repl.it workspaces.如果您的代码正在写入本地文件,例如通过
open('some_file.txt')
,那么这些仅限于单个用户的 Repl.it 工作区。
If you must use files, then you could use any of the Dropbox, Git, AWS S3, Google Drive Python libraries to read/write external files.如果您必须使用文件,那么您可以使用 Dropbox、Git、AWS S3、Google Drive Python 库中的任何一个来读/写外部文件。
However, the better solution would be to use a hosted database solution and connect Repl.it to that.但是,更好的解决方案是使用托管数据库解决方案并将 Repl.it 连接到该解决方案。 Some popular (free) examples include Firebase, Mongo Atlas, or Datastax Astra.
一些流行的(免费)示例包括 Firebase、Mongo Atlas 或 Datastax Astra。 For a simple leaderboard counter, then even Grafana Cloud.
对于简单的排行榜计数器,甚至是 Grafana Cloud。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.