Database-Like File
KiKUP (46)

Hi there repl.it users, I just had a question that I needed answering for a game I'm making. I would like to store the amount of points someone gets in one game in a file after someone quits the game. In addition, I would like to make this file unchangeable by any users except me. How can I do this?

You are viewing a single comment. View All
AllAwesome497 (367)

@KiKUP ok. If u want it hidden to other users:
1) make a file named .env
2)add import ast to the beginning of your code
3) Read the file:

with open('.env', 'r') as f:
    <item name> = ast.literal_eval(f.read())

4)Write data into file:

with open('.env', 'w') as f:
    f.write(str(<item name>))

here's an example of something I did with this: https://repl.it/@AllAwesome497/LOL-Bot