sys.stdin.readlines() hangs Python script
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Everytime I'm executing my Python script, it appears to hang on this line: lines = sys.stdin.readlines() What should I do to fix/avoid this? EDIT Here's what I'm doing with lines : lines = sys.stdin.readlines() updates = [line.split() for line in lines] EDIT 2 I'm running this script from a git hook so is there anyway around the EOF? 回答1: This depends a lot on what you are trying to accomplish. You might be able do: for line in sys.stdin: #do something with line Of course, with this idiom as well as the readlines() method you are using, you