hi i am new in python just started learning with python i got a task in which i need to store "1" byte of integer into different bits just like RGB the value are store in that can any one would write a small program for me and explain that ,please i need a help
Thankyou
I'll assume this question is legitimate and appropriate for the forum..
# To Encode:
r = 1
g = 2
b = 3
rgb = r << 16 | g << 8 | b
#To extract:
r = (rgb >> 16) & 0xFF
g = (rgb >> 8) & 0xFF
b = rgb & 0xFF
要将数字转换为二进制数list(bin(number))[2:]
: list(bin(number))[2:]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.