“Python si principal” Réponses codées

Python si principal

# if __name__ == '__main__' checks if a file is imported as a module or not.
# example: 
def main():
    print('Hello World')
    
if __name__ == '__main__':
    # This code won't run if this file is imported.
    main()
Djebbes Rabah

__name __ == __main__ en python

# If the python interpreter is running that module (the source file)
# as the main program, it sets the special __name__ variable to have
# a value “__main__”. If this file is being imported from another 
# module, __name__ will be set to the module’s name.
if __name__=='__main__':
  # do something
Noobie Nareshhhh

Réponses similaires à “Python si principal”

Questions similaires à “Python si principal”

Plus de réponses similaires à “Python si principal” dans Python

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code