Indenting in a txt file from python script in terminal -
im trying write python script make txt file if there isn't current 1 , add "indent me somewhere onto next line" text it. wondering how text indented in middle of string onto next line least amount of python. everyone.
import sys if not os.path.exists(/users/you/desktop/aimemory.txt) : memory = open("aimemory.txt","w") print("created new memory") else : print("accessing memory") memory = open("aimemory.txt", "r") print(memory.read()) memory.close() memory = open("aimemory.txt", "a") memory.write("indent me somewhere onto next line")
you need put tab character , linefeed @ end, like:
memory.write("\tindent me somewhere onto next line\n")
Comments
Post a Comment