Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
UART write binary code
#3
You could try this (perhaps not the most efficient)
>>> bytes([int('00001111', 2)])
b'\x0f'
>>> int('00001111', 2).to_bytes(1, 'little')
b'\x0f'
« We can solve any problem by introducing an extra level of indirection »
Reply


Messages In This Thread
UART write binary code - by trix - Apr-28-2024, 08:37 AM
RE: UART write binary code - by Larz60+ - Apr-28-2024, 08:44 AM
RE: UART write binary code - by Gribouillis - Apr-28-2024, 09:07 AM
RE: UART write binary code - by deanhystad - Apr-28-2024, 04:57 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  write code that resides in parent directory franklin97355 3 642 Apr-14-2024, 02:03 AM
Last Post: franklin97355
  How Write Part of a Binary Array? Assembler 1 484 Jan-14-2024, 11:35 PM
Last Post: Gribouillis
  needing some help to write some code for a game calculator rymdaksel 1 581 Jan-02-2024, 09:56 AM
Last Post: deanhystad
  UART & I2C slow down a loop trix 4 787 Dec-28-2023, 05:14 PM
Last Post: trix
  Python Code for Preorder Traversal of a Binary Tree Bolt 1 717 Sep-22-2023, 09:32 AM
Last Post: Gribouillis
  How do I read and write a binary file in Python? blackears 6 8,351 Jun-06-2023, 06:37 PM
Last Post: rajeshgk
  How to clean UART string Joni_Engr 4 2,658 Dec-03-2021, 05:58 PM
Last Post: deanhystad
  UART Serial Read & Write to MP3 Player Doesn't Work bill_z 15 6,256 Jul-17-2021, 04:19 PM
Last Post: bill_z
  Read/Write binary file deanhystad 3 3,402 Feb-01-2021, 10:29 AM
Last Post: Larz60+
  How to write a code with İF function? Aycaaxx 1 1,953 Nov-03-2020, 05:46 AM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020