简体   繁体   中英

How to include your run-time code in a main method in Python?

This was asked at the end of a Python challenge. [Here is the link to the challenge][1] I would really appreciate it if you could explain it to me or address me to documentation in this subject. I have searched for it and I am not sure if the answers I came across are relevant to this question. Here is the most relevant code I found.

    import time
    start_time = time.time()
    main()
    print(f"{time.time() - start_time} seconds") 

My question is: is this what the exercise asked for? and if not, what is the answer? [1]: https://www.practicepython.org/exercise/2014/05/28/16-password-generator.html

It means that everything you write for this problem should be inside a main() function, like so:

def main():
    #some statements here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM