[Python] Weird Behavior of np.loadtxt()

Discussão em 'Python' iniciado por Stack, Março 29, 2025.

  1. Stack

    Stack Membro Participativo

    I'm currently reading a neural network project using debug tool in VScode. There is a function

    def load_img_name_list(dataset_path):

    img_name_list = np.loadtxt(dataset_path, dtype=np.int32)
    return img_name_list


    I constantly stuck and got ValueError could not convert string '2007_000032' to int32 at row 0, column 1.. Since my txt file has data like "2007_000032", I'm not surprised.

    BUT when I run (NOT debug) it was totally fine?! If I print the first 5 item in the list, it shows image_name_list: [2007000032 2007000039 2007000063 2007000068 2007000121].

    They both run in the same environment, I'm so confused about what is going on, can anyone help please? Any help is appreciated!!!

    Continue reading...

Compartilhe esta Página