I am trying to compile :

new_value = int(1500).to_bytes(2, byteorder='little')

but it throws error in Python 3.5 and 3.8.

I am new in python and couldn't find an explanation on this. And also how to read a data from object array

  • Your question would be better if it had the exact versions of python and the error message from those version. Can you give an example of the object array you want to read? – ukBaz Jul 14 at 5:50
  • @ukBaz i knew how to do the cast & conversion but as i can see, it stores in object array. What if i want to read say (btn.ReadValue({})) which i want to read the byte only,say 1 or 0? Currently i am reading the change via value = prop_changed.get('Value', None) – R.M.S.Sundram Jul 16 at 3:26
  • Is your question, how to convert [0] -> 0 and [1] -> 1? – ukBaz Jul 16 at 6:07
  • Yes. Thank you :) – R.M.S.Sundram Jul 16 at 7:04
  • int.from_bytes(value, byteorder="little") – ukBaz Jul 16 at 7:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.