You would want to use the Python SPARQL client wrapper. That abstracts away the parsing of the result and provides you a more Pythonic interface to it: sparql-client · PyPI
That client is not available on the server at the moment, so you’d need to request it be installed from Anvil support.