Why do you define main() instead of just using it?

Asked 1 years ago, Updated 1 years ago, 95 views

def main():
    # Which chord?

if __name__ == "__main__":
    main()

Why do you just do it like that from the top of the file when you have to define the main() in this way?

coding-style python

2022-09-21 21:34

1 Answers

If __main__ is not checked, the entire script will be executed even if this module is imported and written.

For more information, why do you write if_name__=="_main_"?See (Click )


2022-09-21 21:34

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.