I've been trying to figure this out on my own but I'm stuck. I want to add an empty folder to an existing folder in an existing KML file. This is what I have so far, when I open the file, there's no new folder named "test".
import pykml
from pykml.factory import KML_ElementMaker as KML
from pykml import parser
x = KML.Folder(KML.name("test"))
with open("Scratch Paper.kml") as f:
doc = parser.parse(f).getroot()
a = doc.Document.Folder.Folder[0]
a.append(x)
f.close()