Write new line at the end of a file

Viewed 3564

I am working with a numpy array in python. I want to print the array and its properties to a txt output. I want the text output to end with a blank line. How can I do this?

I have tried:

# Create a text document of the output
with open("demo_numpy.txt","w") as text:
    text.write('\n'.join(map(str, [a,shape,size,itemsize,ndim,dtype])) + '\n')

And also:

# Create a text document of the output
with open("demo_numpy.txt","w") as text:
    text.write('\n'.join(map(str, [a,shape,size,itemsize,ndim,dtype])))
    text.write('\n')

However, when I open the file in GitHub desktop, I still get the indication that the last line of the file is "dtype"

2 Answers
Related