Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
74 views
in Technique[技术] by (71.8m points)

python - how to load file as array?

I'm trying to write a file with many array ,every array in 1 line, and after that I need to use this data but in 2 category the firsts elements of the array are the input data and the others are the output but when I write this code I got nothing just white lines

here is my code:

IM = np.array(image)
img = Image.open('Image.bmp')
R = img.crop((235, 100, 255, 120))
for j in range(20):
    for i in range(20):
        [r, v, b] = R.getpixel((i, j))
        s = [r, v, b]
        A = [1, 0, 0]
        v = s + A
        f = open("C:image echantillonDATAT12", 'a')
        f.writelines(str(v) + "
")
        f.close()
f = open("C:image echantillonDATAT12", 'r')
H = f.read()
X = np.array(3)
Y = np.array(3)
for ligne in H:
    X = np.array(ligne[0:2])
    Y = np.array(ligne[3:5])
f.close()
for i in range (3):
    print (X, Y)
 

and this is my file:

[161, 118, 140, 1, 0, 0]
[51, 56, 80, 1, 0, 0]
[21, 23, 22, 1, 0, 0]
[14, 17, 18, 1, 0, 0]
[14, 15, 12, 1, 0, 0]
[14, 15, 10, 1, 0, 0]
[14, 15, 9, 1, 0, 0]
question from:https://stackoverflow.com/questions/65882110/how-to-load-file-as-array

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...