sys.stdin.readline() reads without prompt, returning 'nothing in between'

前端 未结 6 2307
被撕碎了的回忆
被撕碎了的回忆 2021-02-12 15:49

I have a function that executes the following (among other things):

userinput = stdin.readline()
betAmount = int(userinput)

Is supposed to tak

6条回答
  •  轮回少年
    2021-02-12 16:28

    Try this ...

    import sys
    buffer = []
    while True:
        userinput = sys.stdin.readline().rstrip('\n')
        if userinput == 'quit':
            break
        else:
            buffer.append(userinput)
    

提交回复
热议问题