当前位置: 动力学知识库 > 问答 > 编程问答 >

Python Eclipse output to an external text file

问题描述:

I have a long running code which outputs stuff every minute. I will be running it all night and will check results in the morning.

Is there a way to write all the Console stuff to an external text file. I do not want to modify the code, but just looking to direct all Console output to an external file. I am working in Eclipse. I tried the Run -> Run Configurations... -> Your Application -> Common tab -> File idea but the output is horrible - no line breaks.

Is there a way to get the exact same output as the Console into a text file - all formatted nicely?

Many thanks in advance.

RS

网友答案:

you can add a text file. If you write your code to a file which is in a specific directory or if you know the name of it, your program can recognize this. For example, if your variable is words, you can write words = open("what your file is called") then at the end of you code end by writing to file: file.write(string)

分享给朋友:
您可能感兴趣的文章:
随机阅读: