只需要在开头加上一句即可
import numpy as np
np.set_printoptions(threshold=np.inf)
Python 输出到文本中
参考:https://blog.csdn.net/u010624166/article/details/80140002
import sys
print " "#里面为你需要输出的内容
output=sys.stdout
outputfile=open('output.txt', 'a')
sys.stdout=outputfile
若需要关闭输出。则
f=open('log.txt','w')
__console__ = sys.stdout #把默认的“板子” - 命令行做个备份,以便可以改回来
sys.stdout = f
print 1
sys.stdout = __console__
print 2
若输出中带有中文,则添加
type=sys.getfilesystemencoding()#python编码转换到系统编码输出
整理关于Python读取图像的像素
参考:https://blog.csdn.net/search7/article/details/75528537
若用PIL(pillow)则
from PIL import Image
img=Image.open('0.png')
img_array=img.load()
然后就可以通过img_array[x,y]来读取像素值了
另外img.size查看图像的大小,也可以通过img_arrayx,y来设置RGB像素值
为了想要看到所有的像素值,所以转换成numpy格式如上读取
import numpy as np
import cv2
img=cv2.imread('0.png', 'a')