If you truly want to load the Python script from the onload() event, you can try this:
... or ...
But this assumes that JavaScript is enabled in the browser on the user end.
You don't even need to; as the first example shows, have a function defined.
I assume you know that; just like the onclick() event of a button, the body's onload() event, is an event - not a method per se.
Events can call methods, but they are asynchronous by design.