I hope this link helps you out: https://community.tableau.com/thread/152463
One of the posts in the thread mentioned the following which is worth exploring:
If you're looking to generate a TWBX dynamically, you should rename your .twbx file to .zip, extract the contents and you can do whatever you want with those in Python to dynamically create or adjust a workbook file. The structure / definition of the workbook file is just XML so no special code needed to read and parse that.