“So überprüfen Sie, ob var Python existiert” Code-Antworten

So überprüfen Sie, ob in Python eine Variable vorhanden ist

#if the variable is local: 
if 'myVar' in locals():
  # myVar exists

#if the variable is global:
if 'myVar' in globals():
  # myVar exists.
Worried Wryneck

So überprüfen Sie, ob var Python existiert

# for local
if 'myVar' in locals():
  # myVar exists.
# for globals
if 'myVar' in globals():
  # myVar exists.
Filthy Fish

Ähnliche Antworten wie “So überprüfen Sie, ob var Python existiert”

Fragen ähnlich wie “So überprüfen Sie, ob var Python existiert”

Weitere verwandte Antworten zu “So überprüfen Sie, ob var Python existiert” auf TypeScript

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen