本文共 643 字,大约阅读时间需要 2 分钟。
说明:
>>> help(hex)Help on built-in function hex in module __builtin__:hex(...) hex(number) -> string Return the hexadecimal representation of an integer or long integer.>>> help(oct)Help on built-in function oct in module __builtin__:oct(...) oct(number) -> string Return the octal representation of an integer or long integer.>>> help(bin)Help on built-in function bin in module __builtin__:bin(...) bin(number) -> string Return the binary representation of an integer or long integer.>>>示例:
print hex(20),hex(-20) #转换成十六进制print oct(20),oct(-20) #转换成八进制print bin(20),bin(-20) #转换成二进制结果:
0x14 -0x14
024 -024 0b10100 -0b10100转载地址:http://bnyai.baihongyu.com/