If Marty is connected to a WiFi network, you'll need to know it's IP address to connect to it from Python.
You can use the Marty v2 app to find this out, or you can use a network scanning tool, if you prefer
Connect to your Marty, and then select the “Configure Marty” button
You will see Marty's WiFi status listed, including the IP address
Marty can't be used over both bluetooth and WiFi simultaneously, so you will need to disconnect the app before you connect to Marty from Python