0

I am creating an bot.

I have almost finished my project, the only addition I wanna add in is, I want to make a text file or database, in which i can input/select: User; Preferences(such as "Chole" need a female voice as the bot), etc.

I want to make it as

user = input("Hello! Are you a new user or you are already regestered? "

from "database" . . .

if user is new them it should create a new user, I hope y'all get the idea.

So to sum: Want to create a file in the PyCharm project itself, that i can edit, modify, add and check for the users

Relpire
  • 1
  • 1
  • What have you tried? Have you searched "how to create/read a text file in Python"? – enzo Nov 07 '21 at 17:50
  • Lol no actually, I mma try that, I prob should have done that first. – Relpire Nov 07 '21 at 17:57
  • Altho I had read some pages about it, tho i have some questions, https://www.geeksforgeeks.org/reading-writing-text-files-python/ – Relpire Nov 07 '21 at 17:58
  • That's nice! You can [edit your question](https://stackoverflow.com/posts/69875065/edit) including what you didn't understand. – enzo Nov 07 '21 at 17:59
  • Such as Do I have to create a file first, is there a way of making it using a function? All i see are read / read write appen etc. – Relpire Nov 07 '21 at 17:59
  • You can [check if the file exists](https://stackoverflow.com/q/82831/9997212). If it does, read it. If it does not, open it using the write mode and close it (it'll create an empty file). That's the basic idea. You can [read the documentation](https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files). – enzo Nov 07 '21 at 18:07
  • Ahh okay Thank You very much that was honestly my query. – Relpire Nov 08 '21 at 02:49
  • Please provide enough code so others can better understand or reproduce the problem. – Community Nov 08 '21 at 08:44

0 Answers0