본문 바로가기 메뉴 바로가기

달래내

프로필사진
  • 글쓰기
  • 관리
  • 태그
  • 방명록
  • RSS

달래내

검색하기 폼
  • 분류 전체보기 (22)
    • Projects (3)
    • 개발 (0)
      • Dart (1)
      • iOS (1)
      • Android (2)
      • Linux (7)
      • Python (2)
      • Node.js (0)
      • 오픈소스 (0)
      • Issue (0)
      • API (2)
      • Javascript (1)
      • Docker (2)
    • 일상 (1)
  • 방명록

개발/Python (2)
python bytearray to hex string

bytearray to hex string bytesvalue = b'\xf0\xf1\xf2\xf3\xf4\xf5' hexvalue = bytesvalue.hex() print(hexvalue) hex string to bytearray hexstring = 'f0f1f2f3f4f5' datafromhex = bytes.fromhex(hexstring) print(datafromhex)

개발/Python 2022. 12. 7. 09:52
[Python] Hex string to Int, bytes와 bytearray 활용

파이썬으로 시리얼통신을 구현할 때 필요했던 부분을 메모 1. 4바이트 헥사문자열을 10진수 아스키 문자열로 변환하기 2. 아스키 문자열의 길이가 10자리가 되지 않는다면 0(0x30)으로 채우기 3. 패킷데이터 변경이 필요한 버퍼는 bytearray로 사용하기 hexstr = "1a2b3c4d" # Hex String to Int dec = int(hexstr, 16) print(dec) # 10자리 문자열로 변환 (10자리가 안되면 0으로 채우기) decstr = format(dec, '010') print(decstr) data = bytes(decstr, encoding="utf-8") # 변경할 수 없는 배열 print(data) sendbuffer = bytearray([0x02, 0x30, 0..

개발/Python 2022. 3. 15. 14:17
이전 1 다음
이전 다음
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
  • sms api
  • setTimeout
  • Android Bar Color
  • 어바니엘
  • AlertDialog
  • Naver Cloud Platform
  • ProgressBar
  • Window Status Bar
  • Shell Script
  • 롯데캐슬
  • 루미니
  • clearTimeout
  • Bad mode in Synchronous Abort handler detected
  • viewDidAppear()
  • 다트 플러터
  • SHORT URL
  • action bar
  • whose view is not in the window hierarchy
  • wsl lsblk
  • Nginx #NodeJS #웹서버 #포트포워딩 #웹호스팅 #백엔드개발 #웹개발 #웹프로젝트 #서버관리 #웹애플리케이션
  • viewDidLoad()
  • USB Mass Storage
  • raspberrypi serial
  • artik710
  • wsl usb mount
  • usbipd attach
  • Dart Flutter
  • sms
more
«   2026/04   »
일 월 화 수 목 금 토
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30
글 보관함

Blog is powered by Tistory / Designed by Tistory

티스토리툴바