x=(np.arange(np.max(x)+1)==x[:,None]).astype(np.integer) 参考文献: https://blog.csdn.net/fu_shuwu/article/details/78964462 相关文章: 2022-12-23 2021-04-22 2021-07-09 2021-06-21 2021-09-06 2022-01-21 2022-02-22 2021-06-23