如何在python中将数据写入文本文件? [英] How to write a data to a text file in python?

查看:82
本文介绍了如何在python中将数据写入文本文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对python很了解,因此我以python开始了我的第一个代码,但是我无法将数据写入文本文件.谁能帮我将此处的数据写入文本文件:

I am a knew to python and I started my first codes in Python but I can not write my data to a text file. Can anyone help me in writing my data here to a text file:

我正在使用Python 3.4

I am using Python 3.4

 In [66]:data
 Out[66]: 
                                  var1         var2
 20:22:49.999985        0.2160       0.1720

推荐答案

您可以

file = open('filename', 'w');
file.write(data.to_string());    // if data is a pandas.DataFrame object
file.close();

这篇关于如何在python中将数据写入文本文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆