Converting array to string in Python

I used numpy to do this. I have a text file containing a series of numbers:

[  11.1   44.0   74.9  103.8  115.8
  157.0   170.1  208.4   239.9  296.8]

How do I convert the text file to:

11.10377777 44.03133786 74.9749492 103.83874619 115.83058441 157.0862515 170.10200524 208.4376871 239.90138829 296.86073327

stim = a[0,61:71] 
stim2 = a[0,21]
fname = 'blah'
f_events = open('L:\\directory\\' + blah + '.txt',"w")
f_events.write(str(stim-stim2))
f_events.close()

Answers


use " ".join ... but you need to map your floats to string inside the join

with open('L:\\directory\\' + blah + '.txt',"w" ) as f_events:
    f_events.write(" ".join(map(str,stim-stim2)))  #this line :)

Need Your Help

What causes this strange result in Python when assigning to values in a dictionary?

python numpy dictionary variable-assignment

I recently reduced a bug in some code to being a result of the following behaviour:

getting a IllegalBlockSizeException: Data must not be longer than 256 bytes when using rsa

java rsa encryption

I am using rsa key to encrypt a long string which I will send to my server(will encrypt it with server's public key and my private key) But it throws an exception like

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.