$ [sudo] pip install sitemap42
from sitemap42 import Sitemap
sitemap = Sitemap()
sitemap.append('https://domain.com/page1', )
sitemap.append('https://domain.com/page2', changefreq='daily', priority=0.5, lastmod=datetime.now())
sitemap.tostring()
sitemap.write('sitemap.xml')
from sitemap42 import Sitemapindex
sitemapindex = Sitemap()
sitemapindex.append('https://domain.com/sitemap1.xml')
sitemapindex.append('https://domain.com/sitemap2.xml', lastmod=datetime.now())