Python 3.9 is now generally available.

google.appengine.api.full_app_id.project_id

Parses the domain prefixed project ID from the app_id.

app_id The full partitioned app ID. Looks up from environ if None.
environ Environment dictionary. Uses os.environ if None.

A tuple (partition, domain_name, display_app_id). The partition and domain name might be empty.