This is default featured slide 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

*/

Linux 버전 확인

리눅스에서 버전 확인 하기

커널 확인

user@system:~$ uname -a
 

user@system:~$ cat /proc/version
 

배포판 정보 확인
user@system:~$ cat /etc/*release*
 

Python - Bytes, bytearray vs c struct variable

Python에서 bytes, bytearray 를 다룰 때 참고

Format string - Byte order, size, alignment

기본적으로 C 유형은 시스템의 기본 형식 및 바이트 순서로 표시
첫 번째 문자가 이들 중 하나가 아니면 '@'으로 가정
네이티브 바이트 순서는 호스트 시스템에 따라 big-endian 또는 little-endian으로 구분. 예를 들어 Intel x86 및 AMD64 (x86-64)는 little-endian.  Motorola 68000과 PowerPC G5는 big-endian



Format character



Example

>>> from struct import *
>>> pack('hhl', 1, 2, 3)
b'\x01\x00\x02\x00\x03\x00\x00\x00'
>>> unpack('hhl', b'\x00\x01\x00\x02\x00\x00\x00\x03')
(256, 512, 50331648)

>>> pack('<hhl', 1, 2, 3)
b'\x01\x00\x02\x00\x03\x00\x00\x00'
>>> pack('>hhl', 1, 2, 3)
b'\x00\x01\x00\x02\x00\x00\x00\x03'

>>> unpack('<hhl', b'\x00\x01\x00\x02\x00\x00\x00\x03')
(256, 512, 50331648)
>>> unpack('>hhl', b'\x00\x01\x00\x02\x00\x00\x00\x03')
(1, 2, 3)

Windows PC에서 endian을 지정하지 않고 했을 경우 => 네이티브로 판단하여 intel계열의 little-endian 으로 출력

>>> pack('hhl', 1, 2, 3) # Native'@'를 지정한 것으로 처리
b'\x01\x00\x02\x00\x03\x00\x00\x00'
>>> unpack('hhl', b'\x00\x01\x00\x02\x00\x00\x00\x03')
(256, 512, 50331648)


Little-endian vs Big-endian

>>> pack('<hhl', 1, 2, 3)           # little-endian
b'\x01\x00\x02\x00\x03\x00\x00\x00'
>>> pack('>hhl', 1, 2, 3)           # big-endian
b'\x00\x01\x00\x02\x00\x00\x00\x03'

>>> unpack('<hhl', b'\x00\x01\x00\x02\x00\x00\x00\x03')     # little-endian
(256, 512, 50331648)
>>> unpack('>hhl', b'\x00\x01\x00\x02\x00\x00\x00\x03')     # big-endian
(1, 2, 3)



Python - Type Error

Python에서 아래와 같은 오류가 발생할 경우

A Bytes-Like Object Is Required, Not ‘Str'

  bytes-likes 오브젝트가 필요하니 str 타입 말고 bytes 타입의 변수를 넣으라는 의미로 라이브러리등을 사용하다 보면 주로 발생하고 string type 과  bytes 타입은 아래와 같은 상관 관계가 있다.

str –> 디코딩 –> bytes

bytes –> 인코딩 –> str

text = "Hello"    
text_byte = text.encode('utf-8')
text_str = text_byte.decode('utf-8')
text_byte = "Hello".encode('utf-8')


참고


Python - VS Code에서 Qt Designer로 GUI 개발

VS Code에서 작업할 디렉토리를 선택(여기서는 test01폴더)하고 오른쪽 마우스를 클릭한다.
팝업 메뉴의 제일 아래쪽 PyQT: New Form을 선택하면 Qt Designer가 실행 된다.

새 폼(New form) 창이 뜨며 아래 5가지 Form 중에서 하나를 선택할 수 있다
  • Dialog with Buttons Bottom  - Dialog 타입, OK, Cancel 버튼이 하단 오른쪽에 위치
  • Dialog with Buttons Right - Dialog 타입, OK, Cancel 버튼이 오른쪽 상단에 위치
  • Dialog without Buttons - Dialog 타입, 버튼 없음
  • Main Window - Main window 타입, 상단에 메뉴바, 하단에 상태바
  • Widget - Widget 타입




 


참고