Help! Want to use python to generate a .csv dataset file, how to do it?

I want to generate a .csv two-dimensional flat distribution artificial dataset file. I want to output the values generated in the code to the .csv file. Each line is separated by a comma. There are two columns, such as:
1
the first column represents the value of x, and the second column represents the value of y. The
code is as follows:

from sklearn.datasets import make_blobs
from matplotlib import pyplot

data,target=make_blobs

pyplot.scatter (data [:, 0], data [:, 1], c=target);
pyplot.show ()

the above code can only show the generated picture. I want to output the data, but it"s not right. The code I changed is as follows:

from sklearn.datasets import make_blobs
from matplotlib import pyplot
import sys

data,target=make_blobs

pyplot.scatter (data [:, 0], data [:, 1], c=target);
output=sys.stdout
outputfile=open
sys.stdout=outputfile
pyplot.show ()
outputfile.close ()
sys.stdout=output

after modification, the syntheticdataset.csv file can be generated, but there is no data I want in it. How can I modify it?

Mar.10,2021

I recommend using the csv module to write the csv file:
in your case, the code is like this:

9.079981991444182,-6.625044790626964
7.573744080944893,-3.8307421246142286
0.18689336599603878,-4.4228616757162555
8.17862194498336,-5.8660242485855765
7.627525274619017,-6.08593822120887
-3.3954682566821948,-7.071216921667429
9.393298715364962,-4.7199985116769
Menu