Do Minecraft save files use a Python interface?
How do Minecraft save files work? Is there a Python interface?
You're looking for mclevel.py. This (as the name hints at) allows python to manipulate Minecraft levels. I don't know if it also does minecarts, but I suppose so.
An example of what you can do with it: http://www.minecraftforum.net/viewtopic.php?f=25&t=52183