import re
import numpy as np
import matplotlib.pyplot as plt
a=[]
b=[]
for line in open("t.txt"):
q=re.split('\D',line)
x=int(q[1])
y=int(q[2])
a.append(x)
b.append(y)
print a,b
plt.plot(a,b,'or')
plt.show()
from PIL import Image
def draw():
# read file
pixels_array = []
with open('pixels.txt', 'r') as fp_iter:
for line in fp_iter:
pixels_array.append(eval(line))
# draw
color = (128, 128, 128)
im = Image.new('RGB', (256, 256), (255, 255, 255))
for position in pixels_array:
im.putpixel(position, color)
im.show()
弄好了 但不知是不是最优方法
自己的小程序的话,可以用eval