Skip to content Skip to sidebar Skip to footer

How To Write A Data To A Text File In 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: I am using Pytho

Solution 1:

You can

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

Solution 2:

open('out.txt', 'w').write(data)

Post a Comment for "How To Write A Data To A Text File In Python?"