Jet*_*rey 1 python ipython python-2.7 python-3.x
如何将代码的输出导出到自己的文本文件中?当我运行我的代码时,我从中获取了大量数据.如何导出它以便我可以读取其自己的文本文件中的所有数据行.
你可以用python写文件
with open("out.txt", "w") as f:
f.write("OUTPUT")
Run Code Online (Sandbox Code Playgroud)
或者您可以使用io重定向将输出重定向到文件
$ python code.py > out.txt
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
214 次 |
| 最近记录: |