x=(np.arange(np.max(x)+1)==x[:,None]).astype(np.integer) 参考文献: https://blog.csdn.net/fu_shuwu/article/details/78964462