[Python] Access to integer value [closed]

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

  1. Stack

    Stack Membro Participativo

    I have a problem to handle real integer data in my program about audio data:

    for i in range (0,48):
    audio_data = wf.readframes(1)
    print(f" {struct.unpack("<h", audio_data)}" , end=" ")


    To convert into a 2-bytes integer seems to work. The output is

    (26214,) (26215,) (26214,) (26215,) (26215,) (26212,) (26217,) (26211,) (26217,) (26213,) (26217,) (26209,) (26219,) (26212,) (26215,) (26215,) (26213,) (26215,) (26216,) (26212,) (26217,)


    But the values seem to be still strings, not integers. So I cannot make mathematical operations. And why are there commas?

    I know the int(x,16) function for converting into integer. But I am not able to place it at the right position.

    I tried to plce the int(x,16) function, but without success, syntax error messages are coming all the time.

    Continue reading...

Compartilhe esta Página