int类的常用方法说明
来源:互联网 发布:薛之谦的淘宝店叫什么 编辑:程序博客网 时间:2024/06/14 13:33
一、查看int的方法列表 :dir(int)
[‘abs‘, ‘add‘, ‘and‘, ‘bool‘, ‘ceil‘, ‘class‘, ‘delattr‘, ‘dir‘, ‘divmod‘, ‘doc‘, ‘eq‘, ‘float‘, ‘floor‘, ‘floordiv‘, ‘format‘, ‘ge‘, ‘getattribute‘, ‘getnewargs‘, ‘gt‘, ‘hash‘, ‘index‘, ‘init‘, ‘int‘, ‘invert‘, ‘le‘, ‘lshift‘, ‘lt‘, ‘mod‘, ‘mul‘, ‘ne‘, ‘neg‘, ‘new‘, ‘or‘, ‘pos‘, ‘pow‘, ‘radd‘, ‘rand‘, ‘rdivmod‘, ‘reduce‘, ‘reduce_ex‘, ‘repr‘, ‘rfloordiv‘, ‘rlshift‘, ‘rmod‘, ‘rmul‘, ‘ror‘, ‘round‘, ‘rpow‘, ‘rrshift‘, ‘rshift‘, ‘rsub‘, ‘rtruediv‘, ‘rxor‘, ‘setattr‘, ‘sizeof‘, ‘str‘, ‘sub‘, ‘subclasshook‘, ‘truediv‘, ‘trunc‘, ‘xor‘, ‘bit_length’, ‘conjugate’, ‘denominator’, ‘from_bytes’, ‘imag’, ‘numerator’, ‘real’, ‘to_bytes’]
二、查看方法具体说明:help(int)
bit_length(…)
| int.bit_length() -> int |
| Number of bits necessary to represent self in binary.
| >>> bin(37)
| ‘0b100101’
| >>> (37).bit_length()
| 6
代码举例:
i1= 12345;
print(i1.bit_length());
14
i1= 123;
print(i1.bit_length());
7
(100).bit_length();
7
conjugate(…)
Returns self, the complex conjugate of any int
返回自己
(4569113491365).conjugate();
4569113491365
(0b10010).conjugate();
18
i=15;
i.conjugate();
15
* int.from_bytes(bytes, byteorder, , signed=False)**
Return the integer represented by the given array of bytes.
返回字节系列代表的整数
int.from_bytes(b’\x00\x10’, byteorder=’big’)
16
int.from_bytes(b’\x00\x10’, byteorder=’little’)
4096
int.from_bytes(b’\xfc\x00’, byteorder=’big’, signed=True)
-1024
int.from_bytes(b’\xfc\x00’, byteorder=’big’, signed=False)
64512
int.from_bytes([255, 0, 0], byteorder=’big’)
16711680
int.to_bytes(length, byteorder, *, signed=False)
Return an array of bytes representing an integer
返回代表对应整数的字节系列
(1024).to_bytes(2, byteorder=’big’)
b’\x04\x00’
(1024).to_bytes(5, byteorder=’big’)
b’\x00\x00\x00\x04\x00’
(1024).to_bytes(5, byteorder=’little’)
b’\x00\x04\x00\x00\x00’
(1024).to_bytes(5, byteorder=’little’,signed=True)
b’\x00\x04\x00\x00\x00’
(1024).to_bytes(5, byteorder=’little’,signed=False)
b’\x00\x04\x00\x00\x00’
(1024).to_bytes(5, byteorder=’big’,signed=False)
b’\x00\x00\x00\x04\x00’
- int类的常用方法说明
- Java的常用方法说明
- SimpleDateFormat的常用方法说明
- Path类常用方法说明
- Java中的math类的常用方法及用法说明
- 有关SimpleDateFormat的常用方法说明
- 有关SimpleDateFormat的常用方法说明
- 有关SimpleDateFormat的常用方法说明
- 【转贴】SimpleDateFormat的常用方法说明
- 有关SimpleDateFormat的常用方法说明
- Java的SimpleDateFormat常用方法说明整理
- Java的SimpleDateFormat常用方法说明整理
- Java的SimpleDateFormat常用方法说明整理
- String转int的几种常用方法
- java Thread类常用方法简单说明
- Paint 和 Canvas 类常用方法说明
- StringUtils常用方法说明
- JNI 常用方法说明
- 置换群小结(未完结补充中
- P2022 有趣的数
- python中_str_使用方法
- git使用总结
- RH124-第十三节-虚拟机管理
- int类的常用方法说明
- Enabling gzip compression in the IBM HTTP Server
- 重新认识线程与进程
- fatcache分配空间阅读记录
- 求知过程之POST请求
- python中的self含义及使用方法
- 人脸识别-数据库
- 转载他人CSDN博客方法
- 数字的运算