Is it possible to make Python interpret a script line by line and generate output as if from an interactive shell? [duplicate]
问题 This question already has an answer here : Simulate interactive python session (1 answer) Closed 5 years ago . Considering the following interactive shell session. Python 2.7.5+ (default, Feb 27 2014, 19:37:08) [GCC 4.8.1] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> 1+1 2 >>> 2+5 7 >>> "foo" 'foo' >>> Observe how, after every line, the interpreter will echo the result to the console. If I put those same three commands into a script Foo.py without print