是否可以将输出到python shell的信息保存到txt文件中。将特定信息保存到python shell的txt
我运行Python版本2.7.2
这是什么显示在外壳。
Enter numbers 1... 22,34,35,40,55
Enter numbers 2... 12,14,34,47,49
Enter numbers 3... 1,4,10,19,30
Section 1
The number seqeuce is # 0 0 1 2 1 1 # <--
Section 2
The number seqeuce is # 0 2 0 1 2 0 # <-- This is what I would like to save to txt.
Section 3
The number seqeuce is # 2 2 0 1 0 0 # <--
我环顾四周,并了解如何读,写和附加文件,但不 直接从壳。
我将不胜感激任何建议来解决这个问题。
写的代码是问这个问题,shell给出了答案。如果可能,我想直接从shell中保存答案。 – Howie
我认为最简单的方法就是复制/粘贴答案,诚实。否则,你可以尝试挖掘[这里](http://docs.python.org/library/stdtypes.html#bltin-file-objects)或[here](http://docs.python.org/tutorial/ inputoutput.html#读取与写入文件)。 –
感谢您的反馈意见。 – Howie