Print statements not working when serve_forever() is called?

后端 未结 3 528
半阙折子戏
半阙折子戏 2021-01-03 04:12

I have the following small python script to run a local server for testing some html:

print(\'opened\')

from http.server import HTTPServer, SimpleHTTPReques         


        
3条回答
  •  时光说笑
    2021-01-03 04:32

    import logging
    logging.info('Listening at https://127.0.0.1:8000/ . . .')
    

    Hi, please, consider using logging instead of printing, you do not want bother with all the shortcomings of the print statement. Print is for beginners, may be for interactive mode. All the professional server-side coders rely on logging.

    Check In python, why use logging instead of print? for the full list of logging goodness.

提交回复
热议问题