Flask doesn't print to console

前端 未结 5 1571
生来不讨喜
生来不讨喜 2020-12-28 12:49

I\'m new to flask, and I\'m trying to add print info to debug server side code. When launch my flask app with debug=True, i can\'t get any info print to console

I tr

5条回答
  •  暖寄归人
    2020-12-28 13:38

    You can force to flush stdout directly from print:

    print('enter getJSONReuslt', flush=True)
    

    This way you don't have to print to sys.stderr (which flushes by default).

    The reason for your problem is line buffering. Line buffering makes I/O more efficient with the drawback of not immediately showing prints under some conditions.

提交回复
热议问题