在Python中知道int的字节的方法[带有位类引入] [英] Way to know bytes of an int in Python [with bits class thrown in]
本文介绍了在Python中知道int的字节的方法[带有位类引入]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要知道数字的字节。例如,让我们假设我有
i = 3000
我想知道是否有办法获得单身数字的字节(0x0B和0xB8)。
提前致谢,
Daniele
解决方案
< blockquote>
我需要知道数字的字节。例如,让我们假设我有
i = 3000
我想知道是否有办法获得单身数字的字节(0x0B和0xB8)。
提前致谢,
Daniele
展开 < span class =codeDivider> | 选择 | Wrap | Line数字
只是一个好奇心,但是有没有内置的转换为二进制?例如:
3000 =''101110111000''
首先,谢谢,
lowbyte来自
lowByte =''0x%s''%bytes [2:4]
我发现了另一个解决方案:
展开 | 选择 | Wrap | 行号
Hi,
I need to know the byte which a number is made of. For example, let''s suppose I have
i = 3000
I would like to know if there is a way to get the single byte of the number (0x0B and 0xB8).
Thanks in advance,
Daniele解决方案Hi,
I need to know the byte which a number is made of. For example, let''s suppose I have
i = 3000
I would like to know if there is a way to get the single byte of the number (0x0B and 0xB8).
Thanks in advance,
Daniele
Expand|Select|Wrap|Line Numbers
Just a curiosity but is there any built-in that would convert to binary? For example:
3000=''101110111000''
First of all thanks,
the lowbyte comes from
lowByte = ''0x%s'' % bytes[2:4]
I''ve found also another solution:
Expand|Select|Wrap|Line Numbers
这篇关于在Python中知道int的字节的方法[带有位类引入]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文登录 关闭
扫码关注1秒登录发送“验证码”获取 | 15天全站免登陆