How do you read from stdin?

后端 未结 22 2647
余生分开走
余生分开走 2020-11-21 06:46

I\'m trying to do some of the code golf challenges, but they all require the input to be taken from stdin. How do I get that in Python?

22条回答
  •  暖寄归人
    2020-11-21 07:40

    The following chip of code will help you (it will read all of stdin blocking unto EOF, into one string):

    import sys
    input_str = sys.stdin.read()
    print input_str.split()
    

提交回复
热议问题