简体   繁体   English

将更多行打印到 Python 控制台

[英]Print more lines to Python console

I'm currently working on a large dataset that prints about 6500 lines of data.我目前正在处理一个打印大约 6500 行数据的大型数据集。 Unfortunately, the Python console only prints the last (+-) 100 lines of data, and I would like to expand the console to show all lines.不幸的是,Python 控制台只打印最后 (+-) 100 行数据,我想扩展控制台以显示所有行。 Is there a possibility to do this, or would it be better to export it to eg Excel?是否有可能这样做,或者将其导出到例如 Excel 会更好吗?

Try writing to a text file:尝试写入文本文件:

m = "how to\n"
x = ["write\n","to\n","text\n","file"]
with open("file.txt","w") as file:
    file.write(m)      #str input
    file.writelines(x) #list input

Or if your data needs to be formatted like an Excel file, look into the xlsxwriter module.或者,如果您的数据需要像 Excel 文件一样格式化,请查看xlsxwriter模块。 It's generally much better practice to write data to files rather than print to console as far as I know.据我所知,将数据写入文件而不是打印到控制台通常是更好的做法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM