write the file in the python .... but it's override the old content of the file
f = open("vishal.txt",'w')
f.write("Vishal is the smart boy")
f.close()
if you want to add the text new line without the delete old content
f = open("vishal.txt",'a')
f.write("Vishal is the smart boy test\n")
f.close()
if you want to check how many character you add the file then use the following code
f = open("vishal.txt",'a')
a = f.write("Vishal is the smart boy test\n")
print(a)
f.close()
if you want read and write file at one time now you can use the following code
f = open("vishal.txt",'r+')
a = f.write("test 2\n")
content = f.read()
print(content)
f.close()
Thanks you for commenting your questions. I will see question and respond you.