Hi!
I'm working on a project that will be very useful for many others.
When I was learning Python, I created a program that creates an account for the user.
It had two variables: username and password.
But every time I ran the program, the values of both variables weren't the same.
So, I'm creating this project, that will sove the problem.
The idea is to create a text file that will work as a server.
def CreateFile(name):
try:
with open(f"{name}.txt", "a+"):
return 0
except:
pass
This code will create a text file.
The next time you run the your code, it'll check if the file already exists.
If it does, nothing will happen.
To add informations to the file you can call the function Write():
def Write(name, value):
with open(f"{name}.txt", "a") as file:
file.write(f"[INFO]:{value}]")
As you may have noticed, the text file that you want to acess is a string, not a variable:
# this is TestFile.py
import LocalServer
# creates a text file named MyFile
LocalServer.CreateFile("MyFile")
# adds Hello, World! to MyFile.txt
LocalServer.Write("MyFile", "Hello, World!")
You can test if some text is in your text file or add settings to it.
I'll keep working on this project so that it'll be complete.
Oldest comments (0)