到目前为止,有没有一种快速、方便的方法可以将所有代码输入到 python 解释器中?例如,如果我在解释器中输入:
Steven$ python
Python 2.7.5 (default, Mar 9 2014, 22:15:05)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> print "hi"
hi
>>> a = [1,2,3]
>>> for e in a:
... print e
...
1
2
3
>>> print "bye"
bye
>>>
我想得到这些行:
print "hi"
a = [1,2,3]
for e in a:
print e
print "bye"