Flask doesn't print to console

前端 未结 5 1544
生来不讨喜
生来不讨喜 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

    Try this and see if it helps:

    For python2:

    from __future__ import print_function
    import sys
    
    print('This is error output', file=sys.stderr)
    print('This is standard output', file=sys.stdout)
    

    For python3 you don't need to import from future print_function:

    import sys
    
    print('This is error output', file=sys.stderr)
    print('This is standard output', file=sys.stdout)
    

    See if it helps to print to console.

提交回复
热议问题