How can I do this so that after appending when I run the code again it starts the file off fresh with only the header lines?
with open('svg5.svg','a+') as txt:
you can either append to everything or delete the content.
to keep a spefic string you can have a const like
HEADER = "this is my nice looking header"
with open(filepath,'w') as outfile:
outffile.write(HEADER)
outfile.write(whatever you want)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.