Python 2.7: Print thread safe

后端 未结 2 2106
春和景丽
春和景丽 2020-12-03 08:49

I\'ve seen a similar post here however it refers to Python 2.6 and I was hoping there was an easier way.

From reading the thread it seems the best way is to just re

2条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-03 09:36

    from __future__ import print_function
    print = lambda x: sys.stdout.write("%s\n" % x)
    

    Is a nice cheap and dirty hack.

提交回复
热议问题