write in a text file in proper formatpython code example
Example 1: python file reading
fin = open("NAME.txt", 'r')
body = fin.read().split("\n")
line = fin.readline().strip()
Example 2: read and write to file python
file = open(“testfile.txt”, “r+”)