[Python] Python basic question, to get the datatype

Discussão em 'Python' iniciado por Stack, Setembro 3, 2025.

  1. Stack

    Stack Membro Participativo

    I'm working on a small command-line utility and I need to be able to determine the data type of the user's input. Specifically, I want to check if the input is an integer, a floating-point number, a boolean (True or False), or a simple string. The challenge I'm facing is that the input() function in Python always returns a string, which means I have to manually attempt to convert the value to see if it fits another type. This process has led to some messy try-except blocks and I'm concerned about robustness and efficiency, especially for handling edge cases.
    Can use modules and without modules to check it is correct are wrong.

    Continue reading...

Compartilhe esta Página