Как я мог ввести EOF в SublimeREPL - PullRequest
0 голосов
/ 13 ноября 2018

Как заголовок, мне было интересно, как я мог бы ввести сигнал EOF в sublimeREPL?

Следующий код хорошо работает на CMD, но не может быть остановлен в REPL, потому что я не могу ввести сигнал EOF в REPL.ctl + z здесь не работает.

print("Type integers, each followed by Enter; or input EOF siganl to finish")
total = 0
count = 0
while True:
    try:
        line = input()
        if line:
            n = int(line)
            total += n
            count += 1
    except ValueError as err:
        print(err)
        continue
    except EOFError:
        break

if count:
    print("count = ", count, "total = ", total, "mean = ", total/count)
else:
    print("No valid integer")
...