Issue
I have a array of this type:
xyz = [['nameserver','panel'], ['nameserver','panel']]
How can I save this to an abc.txt file in this format:
nameserver panel
nameserver panel
I tried this using, on iterating over each row:
np.savetxt("some_i.txt",xyz[i],delimiter=',');
It's showing this error:
TypeError: Mismatch between array dtype ('<U11') and format specifier
('%.18e')
Solution
This is a possible solution:
data = [['nameservers','panel'], ['nameservers','panel']]
with open("output.txt", "w") as txt_file:
for line in data:
txt_file.write(" ".join(line) + "\n") # works with any number of elements in a line
Answered By - ybl
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.